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

Réponses (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
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')
.

Catégories

En savoir plus sur Networks dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by