Cannot get integral function to work for two limits
1 次查看(过去 30 天)
显示 更早的评论
I have written a script to determine total energy out of a system.
The energy equation does not work when I attempt to use an interal function for two temperatures.
I have attached the script, from lines 82 to 122 containes the issues I am having.
I am attempting to use the equation C1 + C2*((C3/T)/(sinh(C3/T))^2)+C4*((C5/T_4)/(cosh(C5/T_4))^2 to calculate the specific heat capacity.
Where C1-C5 are given.
The T variable is the integral between two limits.
This calculation of the specific heat capacity is need to be done 6 times.
I have tried setting all the C values to values with different numbers e.g C11-C15 and then the next component to C21-C25.
With every alteration i get this same result.
Any help would be much appreciated
Undefined function 'function_Cp_1' for input arguments of type 'double'.
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in Matlab_Assignment_2 (line 90)
Cp_C4H6O2_i=integral(@function_Cp_1,Ti,T1);
%Enthalpy datum conditions (Kelvin)
Ti=(25+273.15);
%Input temperature (Kelvin)
T1=(183+273.15);
%Output temperatre (Kelvin)
T2=(Exit_temperature_degrees_Celcius+273.15);
%Specific heat capacity of C4H6O2 (J/kmol K)
C1=85298;
C2=135600;
C3=826.44;
C4=72341;
C5=2548.6;
function_Cp_1=@(T_1) (C1+(C2*((C3/T_1)/(sinh(C3/T_1)))^2)+(C4*((C5/T_1)/(cosh(C5/T_1)))^2));
Cp_C4H6O2_i=integral(@function_Cp_1,Ti,T1);
Cp_C4H6O2_f=integral(@function_Cp_1,Ti,T2);
%Specific heat capacity of O2 (J/kmol K)
C1=29103;
C2=10040;
C3=2526.5;
C4=9356.0;
C5=1153.8;
function_Cp_2=@(T_2) (C1+(C2*((C3/T_2)/(sinh(C3/T_2)))^2)+(C4*((C5/T_2)/(cosh(C5/T_2)))^2));
Cp_O2_i=integral(@function_Cp_2,Ti,T1);
Cp_O2_f=integral(@function_Cp_2,Ti,T2);
%Specific heat capacity of CO2 (J/kmol K)
C1=29370;
C2=34540;
C3=1428.0;
C4=26400;
C5=588.0;
function_Cp_3=@(T_3) (C1+(C2*((C3/T_3)/(sinh(C3/T_3))^2)+(C4*((C5/T_3)/(cosh(C5/T_3)))^2)));
Cp_CO2=integral(@function_Cp_3,Ti,T1);
%Specific heat capcaity of H2O (J/kmol K)
C1=33363;
C2=26790;
C3=2610.5;
C4=8896.0;
C5=1169.0;
function_Cp_4=@(T_4) (C1+(C2*((C3/T_4)/(sinh(C3/T_4))^2)+(C4*((C5/T_4)/(cosh(C5/T_4)))^2)));
Cp_H2O=integral(@function_Cp_4,Ti,T2);
Undefined function 'function_Cp_1' for input arguments of type 'double'.
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in Matlab_Assignment_2 (line 90)
Cp_C4H6O2_i=integral(@function_Cp_1,Ti,T1);
0 个评论
回答(1 个)
Alan Stevens
2023-5-26
Try this
%Enthalpy datum conditions (Kelvin)
Ti=(25+273.15);
%Input temperature (Kelvin)
T1=(183+273.15);
%Output temperatre (Kelvin)
Exit_temperature_degrees_Celcius = 100; % Arbitrary value
T2=(Exit_temperature_degrees_Celcius+273.15);
%Specific heat capacity of C4H6O2 (J/kmol K)
C1=85298;
C2=135600;
C3=826.44;
C4=72341;
C5=2548.6;
% Note the .* and ./ in the following line
function_Cp_1=@(T_1) (C1+(C2*((C3./T_1)./(sinh(C3./T_1))).^2)+(C4*((C5./T_1)./(cosh(C5./T_1))).^2));
Cp_C4H6O2_i=integral(function_Cp_1,Ti,T1); % No need for @ here with in-line function
Cp_C4H6O2_f=integral(function_Cp_1,Ti,T2); % ditto
disp([Cp_C4H6O2_i, Cp_C4H6O2_f])
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Computations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!