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 CenterFile Exchange에서 Power and Energy Systems에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by