Error using odearguments due to vector incoherent

조회 수: 2 (최근 30일)
Muhammad Luqman
Muhammad Luqman 2023년 5월 22일
댓글: Muhammad Luqman 2023년 5월 23일
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

채택된 답변

Torsten
Torsten 2023년 5월 22일
편집: Torsten 2023년 5월 22일
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.
  댓글 수: 1
Muhammad Luqman
Muhammad Luqman 2023년 5월 23일
Sir with all of my respect thank you so much, it worked :')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by