ODE45 for phase trajectory plot
11 views (last 30 days)
Show older comments
linoy Ban David
on 18 Dec 2022
Commented: linoy Ban David
on 18 Dec 2022
Hi, I'm new in Matlab.
I used in ODE45 code to find phase trajectory of the following equations:
when my initial conditions are 0,0,0 I run the code with these initial conditions but I don't get any point on the plot. This is the code I wrote:
f1=[0 0 1];
f = @(t,x) [1*x(1)+x(2)-x(1)*x(3);-x(1);-0.9*x(3)+(x(1)^2);];
x0 = [0;0;0];
dt= 0.001;
tspan= 0.1:0.45:10;
[t,x] = ode45(f,tspan,x0);
p%lot3(x(:,1),x(:,2),x(:,3), "o")
u = gradient(x(:,1));
v = gradient(x(:,2));
w = gradient(x(:,3));
quiver3(x(:,1),x(:,2),x(:,3),u,v,w, '-b')
grid on
title('Phase trajectory')
subtitle('g=0.9')
xlabel('x'), ylabel('y'), zlabel('z')
this is the plot that comes out when my initial conditions are 0,0,0:
Is it possible that ODE45 is not suitable for my problem? Where am I wrong?
I would appreciate any help.
0 Comments
Accepted Answer
Cris LaPierre
on 18 Dec 2022
With initial conditions [0,0,0], the results of ode45 are all zeros, so there are no gradients.
Consider adjusting your initial conditions.
f = @(t,x) [1*x(1)+x(2)-x(1)*x(3);-x(1);-0.9*x(3)+(x(1)^2);];
x0 = [0.1;0;0];
tspan= 0.1:0.45:10;
[t,x] = ode45(f,tspan,x0);
plot3(x(:,1),x(:,2),x(:,3), "o")
grid on
More Answers (0)
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!