Getting the wrong output value when running the code
古いコメントを表示
Is anyone able to help me locate why my code is showing the wrong answer when it does the equation. I have the code working perfectly as I wanted it to but when running the code I get answers that are not even correct. Any way to fix this?
Thank you.
t_i='';
t_f='';
t_i = input(strcat(t_i, ' Initial Temperature: \n'));
t_f = input(strcat(t_f, ' Final Temperature: \n'));
T=t_i:2:t_f; %Range of temp. from input value
T=T+273.15; %Conversion of celsius to kelvins
fprintf('Pressure\tTemperature\n'); %to print table in command window
for t=1:length(T)
p = b-(a*0.05333/T(t)); %vapor pressure equation
p = 10.0^p;
fprintf('%f\t%f\n',p,T(t));
end
%output
% Pressure Temperature
% 19.517961 273.150000
% 21.823778 275.150000
% 24.362704 277.150000
% 27.154148 279.150000
% 30.218758 281.150000
% 33.578477 283.150000
% 37.256592 285.150000
% 41.277788 287.150000
% 45.668205 289.150000
% 50.455482 291.150000
% 55.668823 293.150000
% 61.339041 295.150000
% 67.498616 297.150000
% 74.181750 299.150000
% 81.424420 301.150000
% 89.264431 303.150000
% 97.741473 305.150000
% 106.897169 307.150000
% 116.775136 309.150000
% 127.421028 311.150000
% 138.882599 313.150000
% 151.209747 315.150000
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!