Not enough input arguments

12 Ansichten (letzte 30 Tage)
BG88
BG88 am 26 Sep. 2018
Kommentiert: madhan ravi am 26 Sep. 2018
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

Antworten (2)

madhan ravi
madhan ravi am 26 Sep. 2018
Bearbeitet: madhan ravi am 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 Kommentare
Walter Roberson
Walter Roberson am 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
madhan ravi am 26 Sep. 2018
Thank you sir , the reason I put P in each tree is that I thought it might reduce the computational time.

Melden Sie sich an, um zu kommentieren.


Basil C.
Basil C. am 26 Sep. 2018
Bearbeitet: Basil C. am 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

Kategorien

Mehr zu Power and Energy Systems finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by