Cant Run the program

Hi,
I havent used MATLAB for a few months. I downloaded this files: https://ch.mathworks.com/matlabcentral/fileexchange/96494-ieee-std-738-calculation-of-current-temperature-relationship cant solve the problem during the converting. Thanks for the help.
Error in IEEEstd738 (line 9)
Form=formularset(IEEEstd738Para);
FULL CODE OF THE PROGRAM:
function [T_avg,R] = IEEEstd738(T_avg,T_a,V_w,beta,I,t,IEEEstd738Para)
%% IEEESTD738 IEEEstd738_function
%%
% % This code is same as (Fcn) code of MATLAB Function block in simulink file.
%
% % "%" in each sentence so that this code can be copied directly into Fcn.
persistent T_s T_film rho_f mu_f k_f K_angle chi C Z_c theta q_s DT_C Form
if isempty(Form)
Form=formularset(IEEEstd738Para);
%Initial average temperature of the boundary layer
R = Form.R(IEEEstd738Para.R_T_low,IEEEstd738Para.R_T_high,T_avg,IEEEstd738Para.T_high,IEEEstd738Para.T_low);%Resistance at initial temperature
T_s =Form.T_s(I,R,T_avg,IEEEstd738Para.k_th);%Conductor surface temperature
end
%}
%% 0 Calculate days(N) and Solar zenith angle
N=floor(t/(24*3600));
s=rem(t,24*3600);
omega = (s-12*3600)/3600 *15;
%% 1 Calc air condition
T_film = Form.T_film(T_a,T_s);
mu_f = Form.mu_f(T_film);
rho_f= Form.rho_f(IEEEstd738Para.H_e,T_film);
N_Re = Form.N_Re(IEEEstd738Para.D_0,V_w,mu_f,rho_f);
k_f = Form.k_f(T_film);
K_angle = Form.K_angle(beta);
% q_c
q_c1 = Form.q_c1(K_angle,N_Re,T_a,T_s,k_f);
q_c2 = Form.q_c2(K_angle,N_Re,T_a,T_s,k_f);
q_c = max(q_c1,q_c2);
% q_r
q_r = Form.q_r(IEEEstd738Para.D_0,T_a,T_s,IEEEstd738Para.epsilon);
% q_s
delta = Form.delta(N);
chi =Form.chi(IEEEstd738Para.Lat,delta,omega);
C=180*logical(chi>=0 & 0 <=omega & omega <180) ...
+180*logical(chi<0) + 180*logical(chi<0& 0 <=omega & omega <180);
Z_c = Form.Z_c(C,chi);
H_c = Form.H_c(IEEEstd738Para.Lat,delta,omega);
H_c(H_c<0)=0;
theta = Form.theta(H_c,IEEEstd738Para.Z_1,Z_c);
Q_s = Form.Q_s(H_c);
K_solar =Form.K_solar(IEEEstd738Para.H_e);
Q_se =Form.Q_se(K_solar,Q_s);
q_s = Form.q_s(IEEEstd738Para.D_0,Q_se,IEEEstd738Para.alpha,theta);
q_s(q_s<0)=0;
R = Form.R(IEEEstd738Para.R_T_low,IEEEstd738Para.R_T_high,T_avg,IEEEstd738Para.T_high,IEEEstd738Para.T_low);%Resistance
DT_C = Form.DT_C(IEEEstd738Para.Dt,I,R,IEEEstd738Para.mCp,q_c,q_r,q_s);
T_avg=T_avg+DT_C;
T_s =Form.T_s(I,R,T_avg,IEEEstd738Para.k_th);
end
%%
function Form=formularset(IEEEstd738Para)
% %Steady-state heat balance
Form.I =@(q_c,q_r,q_s,R) sqrt( (q_c+q_r -q_s )/R );
% %Non-steady-state heat balance
Form.DT_C=@(Dt,I,R,mC_p,q_c,q_r,q_s) ( q_s- q_c - q_r + (I)^2 * R )/mC_p *Dt;
% %Convective heat loss
Form.N_Re=@(D_0,V_w,mu_f,rho_f) D_0*rho_f*V_w / mu_f;
% %temperature of the boundary layer
Form.T_film = @(T_a,T_s) ( T_s + T_a ) /2;
% %Forced convection
Form.q_c1 = @(K_angle,N_Re,T_a,T_s,k_f) K_angle * (1.01+1.35*N_Re^(0.52) ) ...
*k_f * (T_s - T_a);
Form.q_c2 = @(K_angle,N_Re,T_a,T_s,k_f) K_angle * (1.01+1.35*N_Re^(0.52) ) ...
*k_f * (T_s - T_a);
% %Wind dir
Form.K_angle = @(beta) 1.194 - sind(beta) -0.194*cosd(2*beta)+ 0.368*sind(2*beta);
% %Radiated heat loss rate
Form.q_r =@(D_0,T_a,T_s,epsilon) ( 17.8 *(D_0) * epsilon ...
* ( ( ((T_s) + 273)/100)^4 - (( (T_a) + 273)/100)^4 ) );
% %Rate of solar heat gain
Form.q_s = @(A_prime,Q_se,alpha,theta) alpha * Q_se * sind(theta) * A_prime;
Form.theta =@(H_c,Z_1,Z_c) acosd (cosd(H_c)*cosd((Z_c -Z_1)) );
% %Conductor electrical resistance
Form.R = @(R_T_low,R_T_high,T_avg,T_high,T_low)...
(R_T_high - R_T_low) / (T_high - T_low)* (T_avg - T_low) + R_T_low;
% %Radial temperature gradient within the conductor
Form.T_s = @(I,R,T_avg,k_th) T_avg-1/2* I^2*R/ (4*pi*k_th);
% %Conductor heat capacity
Form.mC_p = @(m_i,C_p_i) sum(m_i*C_p_i);
% %Dynamic viscosity of air
Form.mu_f = @(T_film) 1.458*1e-6 * (T_film + 273)^1.5 ...
/(T_film +383.4) ;
% %Air density
Form.rho_f = @(H_e,T_film)...
( 1.293 - 1.525*10^-6 * (H_e) + 6.379*10^-9*(H_e)^2 )...
/ (1+0.00367*T_film ) ;
% %Thermal conductivity of air
Form.k_f = @(T_film) ( 2.424*1e-2 + 7.477*1e-5*(T_film) ...
- 4.407*1e-9* (T_film)^2);
% %Altitude of the sun
Form.H_c = @(Lat,delta,omega) asind (cosd(Lat)*cosd(delta)*cosd(omega) + sind(Lat)*sind(delta) );
% %Solar declination
Form.delta = @(N) 23.46* sind( (284+N)/365 *360 );
% %Azimuth of the sun
Form.Z_c=@(C,chi) C + atand(chi);
Form.chi =@(Lat,delta,omega)...
sind(omega) / (sind(Lat)*cosd(omega) - cosd(Lat)*tand(delta) );
% %Total heat flux density at sea level versus
Form.Q_s =@(H_c) (IEEEstd738Para.a + IEEEstd738Para.b*(H_c) + IEEEstd738Para.c*(H_c)^2 ...
+ IEEEstd738Para.d*(H_c)^3 + IEEEstd738Para.e*(H_c)^4 ...
+ IEEEstd738Para.f*(H_c)^5 + IEEEstd738Para.g*(H_c)^6 );
% %Elevation correction factor
Form.Q_se = @(K_solar,Q_s) K_solar *Q_s;
Form.K_solar = @(H_e) 1 + 1.148*1e-4*H_e + (-1.108*1e-8) * (H_e)^2;
end

1 Comment

KSSV
KSSV on 22 Dec 2021
You should specify the full error.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 22 Dec 2021

0 votes

You would get that error if you tried to run the function by pressing the green Run button. You need to create input values for the function and invoke the function from the command line (or from some code)

Asked:

on 22 Dec 2021

Answered:

on 22 Dec 2021

Community Treasure Hunt

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

Start Hunting!