Effacer les filtres
Effacer les filtres

How to solve this error for the calculation of PVmax2? : Array indices must be positive integers or logical values.

2 vues (au cours des 30 derniers jours)
Af= 0.5 ;
Vmax = 33.3333; % Vehicle maximum Speed: 120 Km/h
VGmax= 5.55556; % Vehicle maximum speed at maximum grade (30 degrees)
Vcr = 22.2222; % Crusing Speed : 80 km/h
Mw = 1300;
g = 9.81;
row = 1.1; % Air Density
Cd = 0.0145; % coefficient of drag
mue = 0.015;
alpha = 0;
PVmax1 = (0.5 * row * Cd * Af *(Vmax^2)) + (Mw*g*Vmax(cos(alpha)+ (mue*sin(alpha))));
P1 = ['Average Power to maintain maximum speed = ',num2str(PVmax1), ' Watts'];
disp(P1)
GMax = 30; % maximum vehicle grade
PVmax2 = (0.5 * row * Cd * Af *(VGmax^2)) + (Mw*g*VGmax(cos(GMax)+ (mue*sin(GMax))));
P2 = ['Maximum power at Maximum Grade = ',num2str(PVmax2), ' Watts'];
disp (P2)

Réponse acceptée

Star Strider
Star Strider le 2 Fév 2019
My guess is that you’re missing an operator (possibly a ‘*’ for multiplication) here (note ):
PVmax1 = (0.5 * row * Cd * Af *(Vmax^2)) + (Mw*g*Vmax(cos(alpha)+ (mue*sin(alpha))));
and:
PVmax2 = (0.5 * row * Cd * Af *(VGmax^2)) + (Mw*g*VGmax(cos(GMax)+ (mue*sin(GMax))));
Anyway, when I insert asterisks in thole locations, your code runs.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by