Why are the lines not showing up on my graphs?
2 次查看(过去 30 天)
显示 更早的评论
g=9.81;
Ta=10;
mA=20;
for i=1:100
M=(i-1)*(30/99);
mB=4.05;
mC=M;
mD=M;
JC=0.005*M;
JD=JC;
JA=0.8055;
A=[mA 0 -1 1 0 0 0; (5*JA) 0 0.2 0 0 0 0; (10*JC) 0 0 -0.1 0 0.1 0; 0 mD 0 0 -1 -1 -1; 0 (10*JD) 0 0 0 -0.1 0.1; 0 mB 0 0 -1 0 0; -0.5 1 0 0 0 0 0];
B=[0; Ta; 0; (-mD*g); 0; (-mB*g); 0];
x=inv(A)*B;
aA(i)=x(1); aB(i)=x(2); FA(i)=x(3); TA(i)=x(4); TB(i)=x(5); TC(i)=x(6); TD(i)=x(7);
end
Mvector=linspace(0,30,100);
plot(Mvector, aA(i),'g',Mvector,aB(i),'b-.');
title('Acceleration');
legend('Disk A','Mass B');
xlabel('M (kg)');
ylabel('Acceleration (m/s^2)');
pause
plot(Mvector,aA(i),'g',Mvector,aB(i),'b-.');
title('Acceleration');
legend('Disk A','Mass M');
xlabel('M (kg)');
ylabel('acceleration (m/s^2)');
pause
plot(Mvector, FA(i),'k');
title('Plot 3');
xlabel('M (kg)');
ylabel('FA (N)');
pause
plot(Mvector,TA(i),'g',Mvector,TB(i),'b-.');
title('Plot 4');
legend('Cable A','Cable B');
xlabel('M (kg)');
ylabel('Tension (N))');
pause
plot(Mvector,TA(i),'g',Mvector,TC(i),'b:',Mvector,TD(i),'r-.');
title('Plot 5');
legend('Cable A','Cable C','Cable D');
xlabel('M (kg)');
ylabel('Tension (N)');
pause
plot(Mvector,FA(i)/(mA*g),'k');
title('Plot 6');
xlabel('M (kg)');
ylabel('mu');
0 个评论
采纳的回答
Star Strider
2020-5-25
You are only plotting one point (that being the last point) and it is not possible to plot lines with only one point.
Try this:
Mvector=linspace(0,30,100);
figure
plot(Mvector, aA,'g',Mvector,aB,'b-.');
title('Acceleration');
legend('Disk A','Mass B');
xlabel('M (kg)');
ylabel('Acceleration (m/s^2)');
% pause
figure
plot(Mvector,aA,'g',Mvector,aB,'b-.');
title('Acceleration');
legend('Disk A','Mass M');
xlabel('M (kg)');
ylabel('acceleration (m/s^2)');
% pause
figure
plot(Mvector, FA,'k');
title('Plot 3');
xlabel('M (kg)');
ylabel('FA (N)');
% pause
figure
plot(Mvector,TA,'g',Mvector,TB,'b-.');
title('Plot 4');
legend('Cable A','Cable B');
xlabel('M (kg)');
ylabel('Tension (N))');
% pause
figure
plot(Mvector,TA,'g',Mvector,TC,'b:',Mvector,TD(i),'r-.');
title('Plot 5');
legend('Cable A','Cable C','Cable D');
xlabel('M (kg)');
ylabel('Tension (N)');
% pause
figure
plot(Mvector,FA/(mA*g),'k');
title('Plot 6');
xlabel('M (kg)');
ylabel('mu');
Also, you were overplotting each new plot on the previous one, erasing the previous one. Since it appears you want them on separate figures, this slightly revised code does that. If you want to plot all of them on the sane axes, use the hold function.
7 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 National Instruments Frame Grabbers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!