Adding velocity directions in phase potrait plot
1 次查看(过去 30 天)
显示 更早的评论
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. I have also treid using the quiver function in MATLAB, it still doesn't seem to work. Original code with the equations of motion is included below.
Current Plot:
Desired Plot:
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
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Two y-axis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!