Subscript indices must either be real positive integers or logicals...help please?

yesterday this code ran just fine, but today I went back to check something and I get this error response:
Subscript indices must either be real positive integers or logicals.
Error in cylindertest (line 114)
for a=1:length(pindist+14.5)-1
The code I am trying to run is as follows:
pindistabs=(pindist+14.5)./100;
%here this is a 20 by 1 matrix, which starts at 0
Udrag=1-Upins./UNOpins;
Drag=0;
for a=1:length(pindistabs)-1
trap=.5.*(Udrag(a)+Udrag(a+1)).*(pindistabs(a+1)-pindistabs(a));
Drag=Drag+trap;
end
Drag=Drag*rhowake*L*UNOavgsum^2
This is an attempt to to an integration, its just odd that it was working yesterday but now I am getting an error.
Help would be appreciated. thanks.

 채택된 답변

Star Strider
Star Strider 2014년 11월 22일
Check the length of ‘pindist’ and ‘pindistabs’. My guess is that it’s a scalar, so subtracting 1 from its length results in a=0.

댓글 수: 4

Eli
Eli 2014년 11월 22일
편집: Eli 2014년 11월 22일
you know what I actually just closed out matlab and re opened it and its running.... good grief edit: pindist is a vector with 20 inputs. (a 1 by 20 matrix)
haha yeah somehow.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

Eli
2014년 11월 22일

댓글:

2014년 11월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by