Plotting a scaler and adding a legend to graph
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
David Hill
2022-11-2
% 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
0 个评论
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')
.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!