This is the 4d Lorenz equation. how to solve it on Matlab?
3 views (last 30 days)
Show older comments
dx/dt=y+y^2-a*y*z;
dy/dt=-z^2+b*y*z-u;
dz/dt=x*y;
du/dt=-c*x;
2 Comments
Answers (1)
Yongzhen Mi
on 26 Jul 2021
Hi, Nix Jr. I think the error is that you defined four variables in your differential equations, but you provided only three initial values to the ode45 function. Therefore, ICs should be something like this [5, 5, 5, 5]' (column vector better).
In addition, you can transfer parameters into the target function by using [time, fOUT]=ode45(@(x)test(~,x,a,b,c), t, ICs, OPTs);. In this way, the parameters a, b, and c can be claimed in the main function once, instead of being defined again and again when the target function is called.
2 Comments
Yongzhen Mi
on 26 Jul 2021
Edited: Yongzhen Mi
on 26 Jul 2021
Take this as an example:
a = 5;
b = 20;
c = 1;
d = 0.1;
k = 0.1;
e = 20.6;
h = 1;
F = @(t,Y) [a*(Y(2)-Y(1))-e*Y(4);Y(1)*Y(3)-h*Y(2);b-Y(1)*Y(2)-c*Y(3);k*Y(2)-d*Y(4)];
CI = [3.2 8.5 3.5 2.0]';
T = linspace(0,100,3000);
[t,Y]=ode45(F,T,CI);
plot3(Y(:,1),Y(:,2),Y(:,3))
I drew some pictures and the attractors could be observed. Please try again and hopefully this will work.
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!