Phase portrait doesn't work
Afficher commentaires plus anciens
Hello to everyone. I have a little problem with my task. I don't know if it is right. I am not sure if all the points are okay and the figure which draws it's right. If someone coul help me I will be very happy. I am really no sure if i make it the way i should and if the graphic is supposed to look like this.

It is given the system
x’ = y^3 − 5y − x
y’ = −x – y
The tasks are to find:
a) Find equivalent points on the system.
b) Draw a phase portrait of the system.
c) Determine which equivalent points are stable.
d) To solve the Cauchy problem for a system with initial data x (0) = 0, y (0) = 5 made animation when moving to the point (x (t), y (t)) in the phase space when the time t varies from 0 to 3
%a function which file name is sys.m
function res = sys(t,x)
res = [x(2)^3-5*x(2)-x(1); -x(1)-x(2)];
%a phase portrait
plot([-10,10],[0,0]);
hold on;
plot([0,0],[-10,10]);
hold on;
syms t y1 y2;
f = @(t, y) [y1.^3 - 5.*y1 - y2; -y2 - y1];
F = f(t,[y1;y2]);
[x,y] = solve(F(1), F(2), y1, y2);
plot(x, y, '*');
axis([-10, 10, -10, 10]);
[x0, y0] = ginput(1);
while 1
[t, x] = ode45(@sys, [0, 10], [x0, y0]);
plot(x(:,1), x(:,2), 'g')
[t, x] = ode45(@sys, [0, -10], [x0, y0]);
plot(x(:,1), x(:,2), 'b')
[x0, y0] = ginput(1);
end
%animation
[t,x] = ode45(@sys, [0, 3], [0, 5]);
for k = 1:length(x)
plot(x(1:k,1),x(1:k,2), 'g');
hold on;
plot(x(k,1),x(k,2), 'x');
axis([-10,10,-10,10]);
M = getframe;
hold off;
end
movie(M);
4 commentaires
darova
le 5 Fév 2021
This line shouldn't work. Didn't you have any problems?

Yoanna Vasileva
le 5 Fév 2021
darova
le 6 Fév 2021
I think it's ok
Yoanna Vasileva
le 7 Fév 2021
Réponses (0)
Catégories
En savoir plus sur Graphics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!