Plotting a scaler and adding a legend to graph

im trying to plot this graph but no joy with the rollt term. also looking to add a coloured legend for the lines
% in m/s
v= 0:1:261;
AirDen= 1.225;
CdA=0.501;
coefficient =0.006;
g=9.81;
m=2149;
Fdrag=(0.5*AirDen*CdA*(v/3.6).^2);
Froll= (coefficient*g*m);
Ft=(0.5*AirDen*CdA*(v/3.6).^2)+(coefficient*g*m);
% plot force against velocity
% using r=0.334m based on d=26inch
r=0.3363;
w=v/r;
torque= Ft*r;
dragt=Fdrag*r;
rollt= Froll*r;
plot(v,rollt)
xlabel('speed in km/hr')
ylabel('torque in Nm')
hold on
plot(v,dragt)
hold on
plot(v,torque)
hold off

답변 (2개)

David Hill
David Hill 2022년 11월 2일
Look at legend to add an appropriate legend.
% in m/s
v= 0:1:261;
AirDen= 1.225;
CdA=0.501;
coefficient =0.006;
g=9.81;
m=2149;
Fdrag=(0.5*AirDen*CdA*(v/3.6).^2);
Froll= (coefficient*g*m);
Ft=(0.5*AirDen*CdA*(v/3.6).^2)+(coefficient*g*m);
% plot force against velocity
% using r=0.334m based on d=26inch
r=0.3363;
w=v/r;
torque= Ft*r;
dragt=Fdrag*r;
rollt= Froll*r;
plot(v,rollt*ones(size(v)))
xlabel('speed in km/hr')
ylabel('torque in Nm')
hold on
plot(v,dragt)
hold on
plot(v,torque)
hold off
Star Strider
Star Strider 2022년 11월 2일
The ‘rollt’ value is a scalar.
If you want to plot it as a funciton of ‘v’ create it a s vector with —
plot(v,rollt*ones(size(v)))
or something similar.
% in m/s
v= 0:1:261;
AirDen= 1.225;
CdA=0.501;
coefficient =0.006;
g=9.81;
m=2149;
Fdrag=(0.5*AirDen*CdA*(v/3.6).^2);
Froll= (coefficient*g*m);
Ft=(0.5*AirDen*CdA*(v/3.6).^2)+(coefficient*g*m);
% plot force against velocity
% using r=0.334m based on d=26inch
r=0.3363;
w=v/r;
torque= Ft*r;
dragt=Fdrag*r;
rollt= Froll*r;
plot(v,rollt*ones(size(v)))
xlabel('speed in km/hr')
ylabel('torque in Nm')
hold on
plot(v,dragt)
hold on
plot(v,torque)
hold off
legend('Roll','Drag','Torque', 'Location','best')
.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2022년 11월 2일

답변:

2022년 11월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by