Why Matlab shows "Index exceeds matrix dimensions"?

1 Ansicht (letzte 30 Tage)
Emir Cabukoglu
Emir Cabukoglu am 27 Mär. 2015
Beantwortet: Image Analyst am 27 Mär. 2015
%Linearized system
SIGMA = 10;
R = 28;
BETA = 8/3;
x=0;
y=1;
z=0;
A=[-SIGMA, SIGMA, 0;
R-z, -1, -x;
y, x, -BETA];
j=3;
dim=3;
N=3;
[Q,~] = qr(rand(dim,j),0);
c = [zeros(1,j-1) 1];
for i=1:N,
QNew = A(: ,(i-1)*dim+1:i*dim)*Q;
[Q,~] = qr(QNew,0);
end
Q0=Q;
for i = (N+1):(2*N+1),
QNew = A(: ,(i-1)*dim +1: i*dim)*Q;
[Q,R] = qr(QNew ,0);
AllR = horzcat(R,AllR);
end
numOfR = size(AllR,2)/j;
for i = 1:numOfR
R = AllR(: ,(i-1)*j+1:i*j);
cNew = R\c;
c = cNew/norm(cNew);
end
w=Q0*c;
I get the error "Index exceeds matrix dimensions.
Error in ginelli (line 21) QNew = A(: ,(i-1)dim+1:idim)*Q;"
Thanks in advance!

Akzeptierte Antwort

Image Analyst
Image Analyst am 27 Mär. 2015
A is 3-by-3. But i*dim can be 9 in the i=1:N loop or 21 in the i = (N+1):(2*N+1) loop. It doesn't have that many columns (9 or 21) - it has only 3.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by