Error: ()-indexing must appear last in an index expression

1 view (last 30 days)
Hello! I am having trouble with a piece of code. This code wasn't written by me it was part of a research project many years back (1998). However I was handed this project in an attempt to recreate this research toward another airfoil. This is my code:
lamdao=4;
v1=7;
N=15000;
nju=15.1e-6; % 20 degrees Celsius
p=4;
rperR=[0.1 0.2 0.3 0.4 0.6 0.8 0.9 1];
%*****************************************
D=sqrt(N/(0.2*v1^3));
R=D/2;
for j=1:length(rperR);
lamda(j)=lamdao*rperR(j);
Czpl(j)=16*pi*R/(9*lamdao*sqrt(lamdao^2*rperR(j)^2+4/9));
ctgI(j)=3*lamdao*rperR(r)(j)/2;
Cz=0.745; %profile NACA 4409
Cx=0.0119; %profile NACA 4409
igr=3.5; %profile NACA 4409
%*****************************************
i=igr*pi/180;
I(j)=atan(1/ctgI(j));
Igr(j)=I(j)*180/pi;
alfa(j)=I(j)-i;
alfagr(j)=afla(j)*180/pi;
eps=atan(Cx/Cz);
epsgr=eps*180/pi;
eta(j)=(1-tan(eps)*cot(I(j)))/(1+tan(eps)*tan(I(j)));
l(j)=Czpl(j)/(p*Cz);
v=2*v1/3;
w(j)=v/sin(I(j));
Re(j)=w(j)*l(j)/nju;
end;
The error I get is "Error: ()-indexing must appear last in an index expression." Can anyone tell me why I get this and how can I fix it ?

Accepted Answer

the cyclist
the cyclist on 8 Mar 2014
Impossible to say for sure, but I think there are two mistakes in the code:
(1) I think you probably need to replace the line
ctgI(j)=3*lamdao*rperR(r)(j)/2;
with
ctgI(j)=3*lamdao*rperR(j)/2;
and
(2) I think there is a typo in the line
alfagr(j)=afla(j)*180/pi;
which should be
alfagr(j)=alfa(j)*180/pi;
At least the code runs to completion then, but I have no way of knowing if the result is correct.

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!