Phase diagram of a second-order differential equation
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello everyone
I have solved a second-order differential equation, and as a result of it I have obtained the values of an angle, phi, and its first derivative on time, phidot, assuming that a time equal to zero both are zero. Now, I would like to do a phase diagram as the one that I have attached. Which is the most suitable function to plot and what I need?

Any suggestion?
댓글 수: 6
darova
2020년 3월 11일
- After that, you define a variable F, which depends on the previous meshgrid, and where you are going to evaluate an expression depending only on Y (maybe Y depends on X somehow)
Variable F in this case is just a derivative
(depends on y only, but should be 2 inputs for ode45)

- After that, you define DY, evaluating F on the X=1 point for all the values created on the meshgrid on Y
The correct form would be as following (i think)
DY = F([],Y); % doesn't matter what X=1 (equation doesn't have X variable)
- and then you define DX somehow (I do not understand that point at all).
I evaluated
, but to plot quiver i need u and v (dx and dy)

So i assign dx=1(always) and dy=4y-16
- Up to which point do you that this approach is compatible with the variables that I have already? Could I use this script directly taking into account that I have already the values of the angular variable and its derivative already calculated?
please show your equation
채택된 답변
darova
2020년 3월 11일
편집: darova
2020년 3월 11일
It's your equation

Assume you have a curve

Then to create a quiver or streamline you need ( ϕ,
, u, v )

I looked here and see that (ϕ,
) in [
]



What is the connection between u, v and
?



So substituting (ϕ,
) in
we have angle



I assume u=1, then v=a
I used parameters you gave
F = @(phi,dphi) -OmegaR^2/4*sin(4*phi) -2*Omegae*gamma*Hy*cos(phi) -2*Omegae*alpha*dphi;
xx = -pi:0.3:pi;
[p,dp] = meshgrid(xx); % grid for phi and dphi
v = F(p,dp)./dp;
u = v*0 + 1;
quiver(p,dp,u,v,'b')
hold on
streamline(p,dp,u,v,xx,xx,'r')
hold off
i got this

streamline somehow didn't work
댓글 수: 9
darova
2020년 3월 12일
Try this
x = 0:0.1:10;
y = sin(x);
u = diff(x);
v = diff(y);
ii = 1:10:length(u); % how many arrows
plot(x,y)
hold on
quiver(x(ii),y(ii),u(ii),v(ii))
hold off
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!