Celsius to Fahrenheit or vice versa
조회 수: 167 (최근 30일)
이전 댓글 표시
채택된 답변
Amit
2014년 1월 21일
disp('This program convert Celsius to Fahrenheit');
Celsius=input('Write a temperature in Celsius and you''ll have the result in Fahrenheit: ');
disp([ 'x = ' num2str(Celsius) ' Celcius and y = ' num2str(Celsius*1.8+32) ' Fahrenheit'])
댓글 수: 1
Amit
2014년 1월 21일
For both cases:
disp('This program convert Celsius to Fahrenheit');
val = input('Type 1 for Celcius to Farenheit and Type 2 for vice versa: ');
switch val
case 1
Celsius=input('Write a temperature in Celsius and you''ll have the result in Fahrenheit: ');
disp([ 'x = ' num2str(Celsius) ' Celcius and y = ' num2str(Celsius*1.8+32) ' Fahrenheit']);
case 2
Faren=input('Write a temperature in Farenheit and you''ll have the result in Celcius: ');
disp([ 'x = ' num2str(Faren) ' Fahrenheit and y = ' num2str((Faren-32)/1.8) ' Celcius ' ]);
end
추가 답변 (4개)
CJ Grucza
2020년 1월 9일
I am able to convert fahrenheit to celsius but i am having a problem with converting celsius to fahrenheit. Why?
댓글 수: 1
Dheeraj Maurya
2022년 6월 30일
disp('This program convert Celsius to Fahrenheit');
val = input('Type 1 for Celcius to Farenheit and Type 2 for vice versa: ');
switch val
case 1
Celsius=input('Write a temperature in Celsius and you''ll have the result in Fahrenheit: ');
disp([ 'x = ' num2str(Celsius) ' Celcius and y = ' num2str(Celsius*1.8+32) ' Fahrenheit']);
case 2
Faren=input('Write a temperature in Farenheit and you''ll have the result in Celcius: ');
disp([ 'x = ' num2str(Faren) ' Fahrenheit and y = ' num2str((Faren-32)/1.8) ' Celcius ' ]);
댓글 수: 1
Walter Roberson
2022년 12월 29일
편집: Walter Roberson
2022년 12월 29일
Needs an end for the switch
Other than the missing end what difference is there compared to https://www.mathworks.com/matlabcentral/answers/113057-celsius-to-fahrenheit-or-vice-versa#comment_191029 ? It looks like you copied that.
Diego
2022년 12월 12일
function [y] = farenheit(C)
y = 9/5 *C + 32;
%farenheit is the name of the file
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!