Phase plot adding direction arrows

11 views (last 30 days)
Brilliant Purnawan
Brilliant Purnawan on 3 Nov 2020
Commented: David Martin on 8 Nov 2022
Hi, need some help regarding adding arrows in velocity plot. So my current plot based on the script extract below yields, the "angular velocity graph" (Don't mind the axis name its suppose to be theta), is there a way to add arrows for the velocity directions? I'm visualizing of something like the second image below.
Image 2
clear all, close all, clc
m = 0.25;
M = 0.635;
l = 0.5;
g = -9.81;
b = 1;
tspan = 0:.001:50;
y0 = [0; -.01; -pi; 0];
[t,y] = ode45(@(t,y)Equation(y,m,M,l,g,b,0),tspan,y0);
g = y(:,3);
figure(2);
plot(y(:,3),y(:,4));
title('Angular Velocity Graph')
xlabel('Time (s)')
ylabel('Angular Velocity (rad s^{-1})')
function dy = Equation(y,m,M,l,g,b,u)
Sinx = sin(y(3));
Cosx = cos(y(3));
a = ((M+m)*l-m*l*Cosx^2);
dy(1,1) = y(2);
dy(2,1) = (u*l-b*y(2)*l-m*g*l*Cosx*Sinx+m*l^2*y(4)^2*Sinx)/a;
dy(3,1) = y(4);
dy(4,1) = (g*Sinx*(M+m)+Cosx*b*y(2)-Cosx*u-m*l*y(4)^2*Sinx*Cosx)/a;
end
  1 Comment
David Martin
David Martin on 8 Nov 2022
I have the same question. An eextensive search has come up with nothing.
I have tried quiver, and it has failed. I have tried adding '->' linespec to the plots, but the triangles were all pointing in the same direction.
I tried annotation arrow, but it only accepts two vectors with two elements as inputs for x and y.

Sign in to comment.

Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!