error using plot vectors must be same length
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rachel Belanger
am 31 Mär. 2021
Kommentiert: Star Strider
am 31 Mär. 2021
% Specify the three inputs
V = [0:10:200]; % Vehicle speed (mph)
Ngear = 6; % Gear number
%Gear Ratio/Efficiency
gear_level = [1:6];
gear_ratio =[4.027 2.364 1.532 1.152 0.852 0.6677]; % [1st 2nd...]
%Final Drive
FD_ratio = 2.56; % Final drive ratio
%Tire
Rw = 0.25; % Tire radius = 0.25m
%Unit Conversion
rps_rpm = 30/pi; % rad/sec to rpm
mps_mph = 2.237; % m/s to mph
G_1= [14.16 14.37 14.57 14.77 14.98 15.35 15.89 16.52 17.15 17.7 18.13 18.45 18.7 18.9 19.09]
G_2= [8.383 8.454 8.525 8.595 8.666 8.737 8.808 8.878 9.003 9.162 9.361 9.572 9.798 10.02 10.2]
G_3= [5.556 5.586 5.617 5.647 5.677 5.708 5.738 5.769 5.799 5.829 5.86 5.89 5.94 6.011 6.08]
G_4= [4.178 4.195 4.212 4.229 4.246 4.264 4.281 4.298 4.315 4.332 4.35 4.367 4.384 4.401 4.418]
G_5= [3.096 3.105 3.115 3.124 3.134 3.143 3.153 3.162 3.171 3.181 3.19 3.2 3.209 3.218 3.228]
G_6= [2.421 2.427 2.433 2.439 2.445 2.45 2.456 2.462 2.468 2.473 2.479 2.485 2.491 2.496 2.502]
figure(1)
plot(V,G_1,'b')
xlim([0 210])
ylim([0 21])
hold on plot(V,G_2,'g')
**and by these "plot" commands it says error using plot vectors not same size**
1 Kommentar
Geoff Hayes
am 31 Mär. 2021
Rachel - V is a 1x21 array and G_1 is a 1x15 array, so the error message makes sense. Should the G_x arrays be of the same size as V?
Akzeptierte Antwort
Star Strider
am 31 Mär. 2021
The ‘V’ vector needs to be defined differently.
One possibility is:
V = linspace(0, 200, numel(G_1)); % Vehicle speed (mph)
defined after the ‘G’ vectors, with the complete code now being:
Ngear = 6; % Gear number
%Gear Ratio/Efficiency
gear_level = [1:6];
gear_ratio =[4.027 2.364 1.532 1.152 0.852 0.6677]; % [1st 2nd...]
%Final Drive
FD_ratio = 2.56; % Final drive ratio
%Tire
Rw = 0.25; % Tire radius = 0.25m
%Unit Conversion
rps_rpm = 30/pi; % rad/sec to rpm
mps_mph = 2.237; % m/s to mph
G_1= [14.16 14.37 14.57 14.77 14.98 15.35 15.89 16.52 17.15 17.7 18.13 18.45 18.7 18.9 19.09];
G_2= [8.383 8.454 8.525 8.595 8.666 8.737 8.808 8.878 9.003 9.162 9.361 9.572 9.798 10.02 10.2];
G_3= [5.556 5.586 5.617 5.647 5.677 5.708 5.738 5.769 5.799 5.829 5.86 5.89 5.94 6.011 6.08];
G_4= [4.178 4.195 4.212 4.229 4.246 4.264 4.281 4.298 4.315 4.332 4.35 4.367 4.384 4.401 4.418];
G_5= [3.096 3.105 3.115 3.124 3.134 3.143 3.153 3.162 3.171 3.181 3.19 3.2 3.209 3.218 3.228];
G_6= [2.421 2.427 2.433 2.439 2.445 2.45 2.456 2.462 2.468 2.473 2.479 2.485 2.491 2.496 2.502];
V = linspace(0, 200, numel(G_1));; % Vehicle speed (mph)
figure(1)
plot(V,G_1,'b')
xlim([0 210])
ylim([0 21])
hold on
plot(V,G_2,'g')
plot(V,G_3,'c')
plot(V,G_4,'m')
plot(V,G_5,'k')
plot(V,G_2,'r')
hold off
.
2 Kommentare
Star Strider
am 31 Mär. 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tires and Vehicles finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!