Trying to convert Kelvin to Celsius in Simscape code
Ältere Kommentare anzeigen
I have a simulation with some Simscape Thermal and Electrical elements. The electrical element is a modification of the stock thermal resistor. The modification uses a nonlinear computation to determine the resistance (the stock thermal resistor is linear).
I discovered I was getting the wrong value because my nonlinear formula is anticipating temperature values in Celsius, however Simscape thermal works in Kelvin.
The code section in question is:
intermediates (Access=private, ExternalAccess=none)
% Calculate R, protecting against negative values
Rdem = R0*(a*T^2 + b*T + c);
R = if Rdem > 0, Rdem else {0,'Ohm'} end;
end
My formula for Rdem depends on T being in Celsius. I could probably change the formula, but I'd rather figure out how to change T to Celsius.
Even if I specify the units of T as 'degC' instead of K in the parameters/variables sections, it seems Simscape does not automatically convert K to degC in my block.
Documentation gives some details about
1) doing the affine conversion in a ps-to-simulink block (but i'm staying in Simscape domain)
2) symbolic toolbox has some unitConvert function but I don't have that toolbox
3) unit conversion block is for Simulink signals, again my signal is in Simscape domain
4) value() function doesn't seem to do the trick:
>> tk = {300, 'K'}; value(tk,'C','affine')
Check for incorrect argument data type or missing argument in call to function 'value'.
5) something else called simscape.Value was introduced in R2021b but I only have R2021a: https://www.mathworks.com/help/physmod/simscape/ref/simscape.value.html
Many thanks for any pointers.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Simscape Electrical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!