ODE45 for phase trajectory plot

9 次查看(过去 30 天)
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.

采纳的回答

Cris LaPierre
Cris LaPierre 2022-12-18
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by