Plotting a scaler and adding a legend to graph

3 visualizaciones (últimos 30 días)
Amir Hussain
Amir Hussain el 2 de Nov. de 2022
Respondida: Star Strider el 2 de Nov. de 2022
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

Respuestas (2)

David Hill
David Hill el 2 de Nov. de 2022
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 el 2 de Nov. de 2022
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')
.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by