Hi, I'm new in Matlab.
I'm trying to create quiver3 for ODE45 (for phase trajectories in the space xyz, I hope I'm using the right function for this), when I runing the code I don't get the arrows in the plot.
this is my code:
f = @(t,x) [1*x(1)+x(2)-x(1)*x(3);-x(1);-0.1*x(3)+(x(1)^2);];
x0 = [0;2;3];
dt= 0.001;
tspan= dt:dt:50;
[t,x] = ode45(f,tspan,x0);
u = gradient(x(:,1));
v = gradient(x(:,2));
w = gradient(x(:,3));
quiver3(x(:,1),x(:,2),x(:,3),u,v,w)
grid on
title('Phase trajectory')
xlabel('x'), ylabel('y'), zlabel('z')
And this is the plot I got:
I would appreciate any help.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 17 Dez. 2022

1 Stimme

The gradient components are much smaller than the coordinates.
You are using a small step size, and the function just isn't very steep compared to the step size

1 Kommentar

linoy Ban David
linoy Ban David am 17 Dez. 2022
Hi Walter,
I changed the values in 'tspan', thank you so much(:

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