Error using odearguments due to vector incoherent

I dont understand what i did wrong with my code, i asked AI and it didnt give me any enlighmentment. anybody please help me please :')
clc; clear;
x0=[1;1;1;1;1]
x0 = 5×1
1 1 1 1 1
tspan=[0 21]
tspan = 1×2
0 21
[x,l] = ode45(@f ,tspan,x0);
Error using odearguments
F returns a vector of length 1, but the length of initial conditions vector is 5. The vector returned by F and the initial conditions vector must have the same number of elements.

Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
plot(l,x)
function dxdl=f(l,x)
d=2;
Ft=0.85;
T0=892;
Cp_Cl=8.6;
Cp_C3=25.3;
Cp_AlCl=28.0;
Cp_2ClC3=30.7;
Cp_HCl=7.2;
U=5;
H1=-48000;
H2=-79200;
T_LMTD=-20;
x1=x(1);
x2=x(2);
dT=x(3);
r1=x(4);
r2=x(5);
dx1dl = r1*pi*d^2/(4*Ft);
dx2dl = r2*pi*d^2/(4*Ft);
dr1dl = 824000*exp(-13700/(T0+dT))*(0.8-x1-x2)*(0.2-x1-x2)/((1-x2)^2);
dr2dl = 46.8*exp(-3460/(T0+dT))*(0.8-x1-x2)*(0.2-x1-x2)/((1-x2)^2);
dCpdT = Ft*((1-5*x1-5*x2)*Cp_Cl+(4-5*x1-5*x2)*Cp_C3+(5*x1)*Cp_AlCl+(5*x2)*Cp_2ClC3+(5*x1)*Cp_HCl);
dTdl = ((pi*d*U*T_LMTD)-(r1*H1+r2*H2)*pi*d^2/4)/dCpdT;
dxdl=@(l,x) [dx1dl;dx2dl;dr1dl;dr2dl;dTdl];
end

 采纳的回答

Use
dxdl=[dx1dl;dx2dl;dr1dl;dr2dl;dTdl];
instead of
dxdl=@(l,x) [dx1dl;dx2dl;dr1dl;dr2dl;dTdl];
But nothing will be plotted because all values returned except for the initial guess are NaN.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

产品

版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by