Phase plot adding direction arrows
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/401769/image.png)
![Image 2](https://www.mathworks.com/matlabcentral/answers/uploaded_files/401774/Image%202.png)
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 commentaire
David Martin
le 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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!