Error Using unitConvert from Celsius to Fahrenheit.

조회 수: 4 (최근 30일)
Robbie
Robbie 2025년 7월 30일
편집: Les Beckham 2025년 7월 30일
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
John D'Errico
John D'Errico 2025년 7월 30일
You would do best to indicate which release you were using when you saw this.

댓글을 달려면 로그인하십시오.

답변 (2개)

Les Beckham
Les Beckham 2025년 7월 30일
편집: Les Beckham 2025년 7월 30일
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')
absK = 
Or, a perhaps more obvious example would be:
T = 20 * u.Celsius;
absF = unitConvert(T, u.Fahrenheit, 'Temperature', 'absolute')
absF = 

Fangjun Jiang
Fangjun Jiang 2025년 7월 30일
Try again. It seems correct to me in R2022b.
  댓글 수: 1
Robbie
Robbie 2025년 7월 30일
I should have clarified, I am trying to use the command/function unitConvert() which when going from Celsius to Fahrenheit converts 100 to 180 in both 2023A and the 2025 version on my tablet. I thought I had included it in the initial post but release must not have saved when I clicked it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by