如何用matlab写这个程序

来源:百度知道 编辑:UC知道 时间:2024/05/31 22:09:42
C=5/9(F-32) 要求输入一个F,出来相应的结果C。必须满足以下条件:
1.让用户输入F,出来相应的C。
2.必须反复接受输入F,出来C,直到用户要求停止。(K = input(‘Do you want to continue the calculation? If yes, please enter Y\n’, ‘s’))

clc;clear;
F=input('请输入华氏温度(°C):');
C=5/9*(F-32);
str=sprintf('相应的摄氏温度为:%f°C',C);
disp(str);
reply=input('Do you want to continue the calculation? If yes, please enter Y\n','s');
while reply=='Y'
F=input('请输入华氏温度(°C):');
C=5/9*(F-32);
str=sprintf('相应的摄氏温度为:%f°C',C);
disp(str);
reply=input('Do you want to continue the calculation? If yes, please enter Y\n','s');
end

clear
K = input(‘Do you want to continue the calculation? If yes, please enter Y\n’, ‘s’);
while K=='Y'
F=input('F=',f);
C=5/9*(F-32)
K=input(‘Do you want to continue the calculation? If yes, please enter Y\n’, ‘s’);
end