Why am I getting the "Undefined function 'File1_2 for input arguments of type 'double' " error message?

2 vues (au cours des 30 derniers jours)
I am trying to solve a system of coupled differential equations with the following code. In one .m file, I write the function with the parameters and equations, and in the other I call ode45 to solve. The error messages I receive when I attempt to run File1_1 are shown below:
Undefined function 'File1_2.m' for input arguments of type 'double'.
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in File1_1 (line 4)
[z,y] = ode45(@File1_2.m,zspan,y0);
function dydt = File1_2(z,y)
K1 = exp(-14.96 + 11070/y(2));
K2 = exp(-1.331 + 2331/y(2));
Ke = exp(-11.02 + 11570/y(2));
R = (y(1)*sqrt(1-0.167*(1-y(1))) - 2.2*(1-y(1))/Ke)/(K1+K2*(1-y(1)))^2;
dydt(1,1) = -50*R;
dydt(2,1) = -4.1*(y(2)-673.2)+10200*R;
end
% This is the first file defining the function
zspan = [0 1];
y0 = [1; 673.2];
[z,y] = ode45(@File1_2.m,zspan,y0);
fracX = 1 - y(:,1);
yyaxis left
plot(z,fracx)
title('X and T plot')
xlabel('z')
ylabel('Fractional Conversion (1-X)')
yyaxis right
plot(z,y(:,2))
ylabel('Temperature (K)')
% This is the second file where I attempt to solve and plot the equations

Réponse acceptée

madhan ravi
madhan ravi le 3 Avr 2020
Modifié(e) : madhan ravi le 3 Avr 2020
@File1_2.m should be without .m
  2 commentaires
madhan ravi
madhan ravi le 3 Avr 2020
Note: MATLAB is case sensitive so either be consistent with fracX or fracx don’t contradict.
Nicholas Wolter
Nicholas Wolter le 3 Avr 2020
Thank you so much, I cant believe I missed that

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by