Trying to solve a 2nd order ODE discretely , that requires external input. What am I doing Wrong ?

Above is the ODE, I am trying to solve.Pr, and f are external inputs. Pr ,Prandtl Number is a and decimal from 0 to 1. While f is a vector obtained from a previous ODE. But, I am receiving this error in Matlab: Error using odearguments (line 92) @(X,Y)TSTAR(X,Y,A,B) returns a vector of length 27, but the length of initial conditions vector is 2. I know the problem is being caused by f, is there a way to fix this?
if true
Eqnold= @(x,y) [y(2);y(3);-y(1).*y(3).*.5];
[eta,f]=ode45(Eqnold,[0:0.4:10],[0;0;0.3320]);
%--------------------------------------------------------------------------
Tstar=@(x,y,A,B) [y(2); -0.5*A.*B.*y(2)];
A = 0.6;
B = f(:,1);
tspan = 0:0.4:10;
y0 = [0 0.332*A^(1/3)];
[t,y] = ode45(@(x,y) Tstar(x,y,A,B), tspan, y0);
plot(1-y(:,1),t/5)
end
Thanks for the help in advance!

2 Commenti

Why don't you solve all equations simultaneously ?
Best wishes
Torsten.
Eqn= @(x,y,T) [y(2);y(3);-y(1).*y(3).*.5;T(2); -0.5*0.6.*y(1).*T(2)];
[eta,funct]=ode45(Eqn,[0:0.5:10],[0;0;0.3320;0;0.332.*0.6^(1/3)])
Would this be the right way to redefine the ODE? I am not sure how I could go about that.

Accedi per commentare.

 Risposta accettata

Eqn=@(x,y)[y(2);y(3);-y(1)*y(3)*0.5;y(5);-0.5*0.6*y(1)*y(5)];
...
Best wishes
Torsten.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by