- #1
grrrp
- 1
- 0
Hello,
before a while I've started studying differential equations in Matlab. I'm solving some problems and I hope that someone could help me.
Firstly I've got to make a phase portrait of this equation:
|x' = y - x^3
|y' = x - y
Here is what I made:
Am I correct?
I've got to make an animation of the movement of a point (x(t),y(t)) in the phase area, if
x(0) = 4 and y(0) = -3 and the time - t, 0 <= t <= 3.
For the second part I don't have an idea.
Could you help me, please?
before a while I've started studying differential equations in Matlab. I'm solving some problems and I hope that someone could help me.
Firstly I've got to make a phase portrait of this equation:
|x' = y - x^3
|y' = x - y
Here is what I made:
C:
%---File - func.m---
function res = func(t,x)
res = [x(2) - x(1)^3,
x(1) - x(2)];
C:
%---File - solve.m---
plot([-7,7],[0,0])
hold on
plot([0,0],[-4,4])
axis([-7,7,-4,4]);
x0 = -14.5;
y0 = -14.5;
while x0 <= 15
[t,x] = ode45(@func, [0,8],[x0,y0]);
plot(x(:,1),x(:,2),'k')
[t,x] = ode45(@func, [0,1],[x0,y0]);
plot(x(:,1),x(:,2),'r')
if y0 >= 15
x0 = x0 + 3;
y0 = -14.5;
end
y0 = y0 + 3;
end
Am I correct?
I've got to make an animation of the movement of a point (x(t),y(t)) in the phase area, if
x(0) = 4 and y(0) = -3 and the time - t, 0 <= t <= 3.
For the second part I don't have an idea.
Could you help me, please?
Last edited by a moderator: