How to solve this error for the calculation of PVmax2? : Array indices must be positive integers or logical values.
조회 수: 2 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
채택된 답변
Star Strider
2019년 2월 2일
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!