*???index exceeds matrix dimensions*
Mostra commenti meno recenti
i n my program i have used 'for' loop and 'if' loop at the end i am getting this comment ???index exceeds matrix dimensions after calculating 1 value, where i have to calculate 42 values
for x=1:42;
if x==1
m=Q0;
h=h0;
b1=0;
end
if x==2
m=Q0;
h=(h0+h1)/2;
b1=0;
end
if x==3
m=Q0;
h=h1;
b1=0;
end
if x==4
m=Q30;
h=h1;
b1=30;
end
if x==5
m=Q30;
h=(h1+h2)/2;
b1=30;
end
if x==6
m=Q30;
h=h2;
b1=30;
end
if x==7
m=Qn45;
h=h2;
b1=-45;
end
if x==8
m=Qn45;
h=(h2+h3)/2;
b1=-45;
end
if x==9
m=Qn45;
h=h3;
b1=-45;
end
*an so on*
%---------------- --------------------%
Ex=ex0+(h)*Kx;
Ey=ey0+(h)*Ky;
Gxy=Gxy0+(h)*Kxy;
Gxy1=Gxy/2;
GSN=[Ex,Ey,Gxy]
GSN1=[Ex;Ey;Gxy1];
%------------------------------------%
GSS=m*GSN
b=b1*(3.14/180);
C=cos(b);
S=sin(b);
%------------------------------------%
T=[C^2,S^2,(2*S*C); S^2,C^2,(-2*S*C);(-S*C),(S*C),((C^2)-(S^2))]
3 Commenti
Jan
il 22 Nov 2011
Please post a copy of the complete error message and the line, which causes the error. Without seeing this line, even wild guessing would be too random.
Andrei Bobrov
il 22 Nov 2011
NOW?
%---------
for x=1:42;
...
end
Ex=ex0+(h)*Kx;
...
T=[C^2,S^2,(2*S*C); S^2,C^2,(-2*S*C);(-S*C),(S*C),((C^2)-(S^2))]
%---------------------------------------
OR
%-------------------------------
for x=1:42;
...
Ex=ex0+(h)*Kx;
...
T=[C^2,S^2,(2*S*C); S^2,C^2,(-2*S*C);(-S*C),(S*C),((C^2)-(S^2))]
end
%----------------------------------
Walter Roberson
il 8 Dic 2011
There is no such thing as an if loop.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!