error 'Index exceeds matrix dimensions.'

3 vues (au cours des 30 derniers jours)
sisay
sisay le 23 Oct 2012
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

Réponse acceptée

Matt J
Matt J le 23 Oct 2012
The DBSTOP command is good for finding errors like these.
  1 commentaire
sisay
sisay le 23 Oct 2012
Thanks I will try this

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 23 Oct 2012
'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.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by