Not enough input arguments

12 ビュー (過去 30 日間)
BG88
BG88 2018 年 9 月 26 日
コメント済み: madhan ravi 2018 年 9 月 26 日
I am new to Matlab and I am currently getting a problem that I do not have enough input arguments.
The code is as follows:
function P = Antoine(T,A,B,C) % vapour pressure [bar]
T = input('Temperature of water in degrees celcius = ')
T_k = 273.15 + T;
P = 10^(A - (B/(T_k + C))); % temperature [K]
if (0 < T) & (T <= 30)
A = 5.40221;
B = 1838.675;
C = -31.737;
end
if (30 < T) & (T <= 60)
A = 5.20389;
B = 1733.926;
C = -39.485;
end
if (60 < T) & (T <= 90)
A = 5.0768;
B = 1659.793;
C = -45.854;
end
end

回答 (2 件)

madhan ravi
madhan ravi 2018 年 9 月 26 日
編集済み: madhan ravi 2018 年 9 月 26 日
function P = Antoine(T,A,B,C) % vapour pressure [bar]
T = input('Temperature of water in degrees celcius = ')
T_k = 273.15 + T;
if (0 < T) & (T <= 30)
A = 5.40221;
B = 1838.675;
C = -31.737;
P = 10^(A - (B/(T_k + C))); % temperature [K]
elseif (30 < T) & (T <= 60)
A = 5.20389;
B = 1733.926;
C = -39.485;
P = 10^(A - (B/(T_k + C))); % temperature [K]
elseif (60 < T) & (T <= 90)
A = 5.0768;
B = 1659.793;
C = -45.854;
P = 10^(A - (B/(T_k + C))); % temperature [K]
end
end
  3 件のコメント
Walter Roberson
Walter Roberson 2018 年 9 月 26 日
The same formula is used for P each time in the code, so you might as well put the P calculation after the if tree.
However, be careful: if the use enters a non-positive T or a T > 90, then the code does not assign a value to P (or to the coefficients needed to calculate P)
madhan ravi
madhan ravi 2018 年 9 月 26 日
Thank you sir , the reason I put P in each tree is that I thought it might reduce the computational time.

サインインしてコメントする。


Basil C.
Basil C. 2018 年 9 月 26 日
編集済み: Basil C. 2018 年 9 月 26 日
The code you have written is correct all that you need to do is to define the variable P after you have defined the value of A,B,C,T (that is at the end of the if statements)
Also no need to use function P = Antoine(T,A,B,C) rather use function P = Antoine() as the arguments that are passed are not used to compute the value of P as they get overwritten
function P = Antoine() % vapour pressure [bar]
T = input('Temperature of water in degrees celcius = ');
T_k = 273.15 + T;
if (0 < T && T <= 30)
A = 5.40221;
B = 1838.675;
C = -31.737;
end
if (30 < T && T <= 60)
A = 5.20389;
B = 1733.926;
C = -39.485;
end
if (60 < T && T <= 90)
A = 5.0768;
B = 1659.793;
C = -45.854;
end
P = 10^(A - (B/(T_k + C))); % temperature [K]
end

カテゴリ

Help Center および File ExchangePower and Energy Systems についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by