error 'Index exceeds matrix dimensions.'

6 次查看(过去 30 天)
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