Why Matlab shows "Index exceeds matrix dimensions"?
1 view (last 30 days)
Show older comments
Emir Cabukoglu
on 27 Mar 2015
Answered: Image Analyst
on 27 Mar 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!
0 Comments
Accepted Answer
Image Analyst
on 27 Mar 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!