Phase Plot - Velocity vs Position

10 ビュー (過去 30 日間)
Martin Romero
Martin Romero 2019 年 4 月 21 日
回答済み: Star Strider 2019 年 4 月 21 日
How can I create a graph of velocity vs position(x' vs x) (phase plot).
Here is the current code I am working with..
function LAB08ex1
m = 1; %mass [kg]
k = 4; %spring constant [N/m]
omega0 = sqrt(k/m);
y0 = 0.1; v0 = 0; %initial conditions
[t,Y] = ode45(@f,[0,10],[y0,v0],[],omega0); % solve for 0<t<10
y = Y(:,1); v = Y(:,2); % time series for y and v
E = (1/2*m*v.^2)+(1/2*k*y.^2); %calculating the energy
figure(1); plot(t,y, 'b+-',t,v,'ro-', t,E, 'gro-'); % retrieve y, v from Y
%-----------------------------------------x
function dYdt = f(t,Y,omega0)
y = Y(1); v = Y(2);
dYdt = [ v ; -omega0^2*y ];

回答 (1 件)

Star Strider
Star Strider 2019 年 4 月 21 日
Unless I am not understanding your code, that would appear to be:
figure(2)
plot(y, v)
grid
xlabel('Position')
yleabel('Velocity')

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by