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.

 Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 18 Dez. 2022

0 Stimmen

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

1 Kommentar

linoy Ban David
linoy Ban David am 18 Dez. 2022
Hi Cris,
Thank you very much for your help! I appreciate it(=

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by