Position-Velocity phase plane portrait in MATLAB?

4 replies · 3K views · last reply
currently
Messages
21
Reaction score
5
TL;DR
How to graph a Position-Velocity phase plane portrait?
For example, how would I graph a Position-Velocity phase portrait of a nodal sink or spiral sink?
Given form of mx'' = -cx' - kx + βx^3.
 
To get a plot you’ll have to numerically integrate it using MATLAB using rk4 or something similar.

If you look online at the Matlab site or do a google search you should be able to find examples to base your solution on.
 
currently said:
Summary:: How to graph a Position-Velocity phase plane portrait?

For example, how would I graph a Position-Velocity phase portrait of a nodal sink or spiral sink?
Given form of mx'' = -cx' - kx + βx^3.

You could also create the system within Simulink and link it to an interactive live Matlab script.

For example, here is a 2nd-order system with some damping (you could also include some extra blocks for your other term)
Simulink block diagram of a second-order system: two integrators in series, feedback gain C, gain omega_n^2, a sum block, and a simout scope output.


Then we link it to the Matlab script:
1. Define our variables
2. Run the simulation and extract the data
3. Plot the data

1.
Setup code excerpt under the heading SET UP: m = 1; N = 1; mu = 0.15; C = mu * N/m; omega_n = 1; initial_x = 10; initial_dxdt = 0;


2.
Code snippet in a monospaced font: t_end = 100 sets the simulation end time, then s = sim('dynamics_friction.slx', 'StopTime', num2str(t_end), 'MaxStep', '0.1', 'SrcWorkspace', 'current'). Below, a sentence explains the ToWorkspace block requirements, followed by code getting tout, simout, velocity Y(:,1) and displacement Y(:,2).


3.
Two MATLAB plots: left, displacement against time, a damped oscillation decaying over time; right, velocity against displacement as a spiral phase portrait titled C=0.15 and mu=0.15, both shown in blue.


Hope that is of some help.

Note: there will be a few more things to define within Simulink, but a youtube introductory video should show you how to use the blocks