Clear Filters
Clear Filters

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

2 views (last 30 days)
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)

Accepted Answer

Star Strider
Star Strider on 2 Feb 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.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!