Inf or NaN whilst trying to run a function

1 view (last 30 days)
SL
SL on 23 May 2023
Commented: SL on 23 May 2023
Hi, I'm very new to MATLAB and I am having some trouble. I'm trying to integrate an equation to solve for specific heat capacity. Could somebody please explain what this error is and how to fix it? Thanks.
T_datum_K = 25+273.15;
T_in_K = 199.3 + 273.15;
T_out_K = 359 + 273.15;
%Ar
C1_Ar = 20786;
C2_Ar = 0;
C3_Ar = 0;
C4_Ar = 0;
C5_Ar = 0;
func = @(T) C1_Ar + C2_Ar.*((C3_Ar./T)./(sinh(C3_Ar./T))).^2 + C4_Ar.*((C5_Ar./T)./(cosh(C5_Ar./T))).^2;
Cp_Ar_in = integral(func, T_datum_K, T_in_K);
Warning: Inf or NaN value encountered.
Cp_Ar_out = integral(func, T_datum_K, T_out_K);
Warning: Inf or NaN value encountered.

Answers (1)

VBBV
VBBV on 23 May 2023
Edited: VBBV on 23 May 2023
T_datum_K = 25+273.15;
T_in_K = 199.3 + 273.15;
T_out_K = 359 + 273.15;
%Ar
C1_Ar = 20786;
C2_Ar = 1;
C3_Ar = 0.1;
C4_Ar = 0.1;
C5_Ar = 0.1;
func = @(T) C1_Ar + C2_Ar.*((C3_Ar./T)./(sinh(C3_Ar./T))).^2 + C4_Ar.*((C5_Ar./T)./(cosh(C5_Ar./T))).^2;
Cp_Ar_in = integral(func, T_datum_K, T_in_K)
Cp_Ar_in = 3.6232e+06
Cp_Ar_out = integral(func, T_datum_K, T_out_K)
Cp_Ar_out = 6.9429e+06
  3 Comments
SL
SL on 23 May 2023
Got it, thank you so much for your help!

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!