absK =
Error Using unitConvert from Celsius to Fahrenheit.
Afficher commentaires plus anciens
When using unitConvert from Celsius to Fahrenheit and vice versa I noticed it was giving me incorrect answers. It is just multiplying or dividing by 9/5ths and forgetting to add or subtract the 32. Is there a way to fix this or is this a bug. Using the unitConvert() function and saw it appeared both 2023a and the mobile version.
1 commentaire
John D'Errico
le 30 Juil 2025
You would do best to indicate which release you were using when you saw this.
Réponses (2)
Les Beckham
le 30 Juil 2025
Modifié(e) : Les Beckham
le 30 Juil 2025
The documentation for unitConvert() specifies that "By default, temperatures are assumed to represent temperature differences." This explains the reason why it doesn't apply the 32 degree offset. It further goes on to explain how to do an absolute temperature conversion. The example that is given is this:
u = symunit;
T = 23*u.Celsius;
absK = unitConvert(T,u.K,'Temperature','absolute')
Or, a perhaps more obvious example would be:
T = 20 * u.Celsius;
absF = unitConvert(T, u.Fahrenheit, 'Temperature', 'absolute')
Fangjun Jiang
le 30 Juil 2025
0 votes
Try again. It seems correct to me in R2022b.

1 commentaire
Robbie
le 30 Juil 2025
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!