Phase portrait doesn't work
古いコメントを表示
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 件のコメント
darova
2021 年 2 月 5 日
This line shouldn't work. Didn't you have any problems?

Yoanna Vasileva
2021 年 2 月 5 日
darova
2021 年 2 月 6 日
I think it's ok
Yoanna Vasileva
2021 年 2 月 7 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!