How to invoke my function in my code ?
4 ビュー (過去 30 日間)
古いコメントを表示
I want to invoke H in my code which is needed to calculate T in for loop. H is enthalpy which is a function of Cp and I attached the function.But I faced an error.Would you please help me to corret it and invoke H in my code truely?
H function:
function [H]=enthalpymethod(T)
syms x
deltaT=2;
T_c=27;
LH=179000; %J/kg
Cps=2000; %J/kg.K
Cpl=2000; %J/kg.K
Cp=(LH/(2*deltaT))+(Cpl+Cps/2);
if T<(T_c-deltaT)
H=vpaintegral(Cps,x,[0 T]);
elseif (T<=(T_c+deltaT)) && (T>=(T_c-deltaT))
H=vpaintegral(Cps,x,[0 T_c-deltaT])+int(Cp,x,[T_c-deltaT T]);
elseif T>(T_c+deltaT)
H=vpaintegral(Cps,x,[0 T_c-deltaT])+int(Cp,x,[T_c-deltaT T_c+deltaT])+int(Cpl,x,[T_c+deltaT T]);
end
end
My code:
clc;
T=zeros(2,1);
T(1,1)=30;
for i=1:2
for j=1
enthalpymethod(T(i+1,j))=enthalpymethod(T(i,j))+20;
end
end
disp(enthalpymethod(T(3,1)))
2 件のコメント
Stephen23
2022 年 3 月 4 日
enthalpymethod(T(i+1,j))=enthalpymethod(T(i,j))+20;
It is unclear what you expect to achieve, but your code syntax is not valid:
You cannot name a variable with the same name as your function.
You cannot allocate data to a function, as you seem to be attempting.
回答 (1 件)
Hannah Mohebi
2022 年 3 月 4 日
3 件のコメント
Torsten
2022 年 3 月 4 日
What is the algebraic equation relating H and T ? Do cps, cp and cpl depend on T ? If not (as in your code from above), you don't need any integration - you can directly solve for H resp.T.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!