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

1 visualización (últimos 30 días)
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

Respuesta aceptada

madhan ravi
madhan ravi el 3 de Abr. de 2020
Editada: madhan ravi el 3 de Abr. de 2020
@File1_2.m should be without .m

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by