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

1 次查看(过去 30 天)
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

采纳的回答

madhan ravi
madhan ravi 2020-4-3
编辑:madhan ravi 2020-4-3
@File1_2.m should be without .m

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by