error 'Index exceeds matrix dimensions.'

조회 수: 7 (최근 30일)
sisay
sisay 2012년 10월 23일
I want to compute the following code but an error which says 'Index exceeds matrix dimensions' appears and I find it puzzling. More to this the 'jj' which suppose to 25 become '1' and 'tcal' changes from 26 to 25.. Here is the code
for ii = 1:length(datafiles);
%%files will be loaded here%%
tcal = max(min(time),min(hTime)):dt:min(max(time),max(hTime));
Sca1 = interp1(time,ssc,tcal);
x= cast(calpre, 'double');
kk=1:1:length(x);
B=repmat(reshape(x(kk),1,1,length(x)),20,40);
M=M(:,:,3);
M1 = permute(M*1000,[2 1]);
M2= interp1(hTime,M1,tcal);
for jj = 1:length(tcal);
h2(:,:,jj)=h(:,:,jj)-B(:,:,jj).*0.001;
sig2(:,:,jj)=sig1(:,:,jj).*(h2(:,:,jj)./h(:,:,jj));
C(:,:,jj) = max(sig2(:,:,jj),[],1
Sca1l = permute(Sca1 ,[3 2 1]);
Sca13(:,:,jj)=interp1(sig1(:,1,jj),Sca1l(:,:,jj),C(:,jj)');
end
end
Any help is highly appreciated

채택된 답변

Matt J
Matt J 2012년 10월 23일
The DBSTOP command is good for finding errors like these.

추가 답변 (1개)

Matt J
Matt J 2012년 10월 23일
'Index exceeds matrix dimensions.' is nothing too mysterious. It happens when you do things like this:
>> x=1:5
x =
1 2 3 4 5
>> x(6)
Index exceeds matrix dimensions.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by