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 日

0 投票

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 件のコメント

linoy Ban David
linoy Ban David 2022 年 12 月 18 日
Hi Cris,
Thank you very much for your help! I appreciate it(=

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by