Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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)

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by