Not enough input arguments
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (2)
madhan ravi
on 26 Sep 2018
Edited: madhan ravi
on 26 Sep 2018
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 Comments
Walter Roberson
on 26 Sep 2018
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
on 26 Sep 2018
Thank you sir , the reason I put P in each tree is that I thought it might reduce the computational time.
Basil C.
on 26 Sep 2018
Edited: Basil C.
on 26 Sep 2018
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
0 Comments
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!