error 'Index exceeds matrix dimensions.'

5 visualizaciones (últimos 30 días)
sisay
sisay el 23 de Oct. de 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

Respuesta aceptada

Matt J
Matt J el 23 de Oct. de 2012
The DBSTOP command is good for finding errors like these.

Más respuestas (1)

Matt J
Matt J el 23 de Oct. de 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.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by