I want to create a function that integrates

1 view (last 30 days)
function H=intCP(A,B,C,D,T1,T2)
syms T
H=A*10^(-3)+B*10^(-5)*T+C*10^(-8)*T^2+D*10^(-12)*T^3;
vpaintegral(H,T1,T2)
end
%%command window
This is the code i wrote
I want to integrate from t1 to t2
intCP
Not enough input arguments.
Error in intCP (line 3)
H=A*10^(-3)+B*10^(-5)*T+C*10^(-8)*T^2+D*10^(-12)*T^3;
intCP(34,45,56,34,566,34)
ans =
-124.62
ans =
(2630622583481433*T^3)/77371252455336267181195264 + (5289050460814003*T^2)/9444732965739290427392 + (9*T)/20000 + 17/500
I dont understand why i get "not enough input argument".
Also, I dont understand why i get two answers.
Thank you
  2 Comments
Rodrigo Blas
Rodrigo Blas on 8 May 2019
mwso3=80.07; %%Mw of so3
mso3=100; %%mass of so3 in kg/hr
nso3=mso3*1000/(60*mwso3); %%mols of so3 mol/s
nso2=2*nso3/(2*.65); %% 64% conversion of so2
no2theo=nso2/2; %%calc theoretical o2
nair=2*no2theo/(.21); %%calc air at 100% xs
no2=2*no2theo; %%actual o2 in
nn2=nair-no2; %%calc n2 in
nso2OUT=nso2-nso3; %%calc so2 OUT
Xtent=(nso2OUT-nso2)/2; %%xtent of reaction
no2OUT=Xtent*2+no2; %%oxygen coming out
R=.08206*10^(-3); %%m^3*atm/mol*k
Tin=450; %%celsius
v1=nso2*R*(Tin+273.15)/1; %%volumetric flow of so2[m^3/s]
v2=(no2+nn2)*R*(Tin+273.15)/1; %%volumetric flow of air
Tout=550; %%temperature out
v3=(nso3+nso2OUT+no2OUT+nn2)*R*(Tout+273.15)/1; %%volumetric flow of products
coeffso2=2; %%mol of so2
coeffo2=1; %%mol of 02
coeffso3=2; %%mol so3
hfso2=-296.90; %%heat of formation so2
hfso3=-395.18; %%heat of fomation so3
hfo2=0; %%heat of formation o2
hfr=coeffso3*hfso3-(coeffo2*hfo2+coeffso2*hfso2); %% Standard heat of formation of osidation of so2
hhat1=intCP(34,45,56,34,566,34);
hhat2=interpolation(11.15,14.24,400,500,450);
hhat3=interpolation(11.72,15.03,400,500,450);
The function is used in "hhat1".
I ran the script with "hhat1" included and now got:
hhat1
hhat1 =
(2630622583481433*T^3)/77371252455336267181195264 + (5289050460814003*T^2)/9444732965739290427392 + (9*T)/20000 + 17/500
Not the answer im looking for. Im looking for a number.

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 8 May 2019
Let's address your questions in turn. First, why "Not enough input arguments"?
intCP
Not enough input arguments.
Error in intCP (line 3)
H=A*10^(-3)+B*10^(-5)*T+C*10^(-8)*T^2+D*10^(-12)*T^3;
The line intCP calls your function with no input arguments. This means that the variables A, B, C, D, T1, and T2 that you declare intCP receives as inputs are not created, because there's no data to use to create them. When you try to then use the (non-existent) variable A in defining H, MATLAB realizes that it doesn't exist. Because the root cause of that problem is that you called intCP with not enough input arguments that's what MATLAB reports in the error.
Second, why two answers?
intCP(34,45,56,34,566,34)
ans =
-124.62
ans =
(2630622583481433*T^3)/77371252455336267181195264 + (5289050460814003*T^2)/9444732965739290427392 + (9*T)/20000 + 17/500
You're not really getting two answers. Only the second of those answers is actually returned from intCP. The -124.62 is displayed by intCP because you called vpaintegral(H,T1,T2) without a semicolon to suppress displaying its output. The symbolic expression involving T is the actual return value, because that's what H (the variable you declared as the output argument in the definition of intCP) contained when the function finished executing.
Third, why not a number? The vpaintegral function does NOT change its inputs in any way, shape, or form. H was a symbolic expression involving T when it was passed into vpaintegral and it remains a symbolic expression involving T when vpaintegral returns. If you want intCP to return the number rather than the symbolic expression, store the output of vpaintegral into H (the output argument) so it is what is returned from intCP, not the symbolic expression.

Categories

Find more on Equations 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!