Index exceeds matrix dimensions

5 vues (au cours des 30 derniers jours)
venuuu
venuuu le 3 Avr 2015
Commenté : Rena Berman le 17 Jan 2018
I've got a problem and because of my bad knowledge of matlab, it would be great if someone know the solution for this problem.
arr = {'01', '02', '03', '04'};
ldir = '/data/.....'
cond= {Forstats_1PLhann.mat};
savedir = ldir;
for i= 1:11;
display (sprintf('analysing subject....%s,arr{i}));
subjectdir=strcat(ldir, 'Tsbj_', arr{i},'/');
load(strcat(subjectdir,cond {1}));
data{1,i} = ft_freqdescriptives ([], PLhann);
clear PLhann
end;
cond= {Forstats3_PLhann.mat'};
for i = 12:22
display (sprintf('analysing subject....%s,arr{i}));
subjectdir=strcat(ldir, 'Tsbj_', arr{i},'/');
load(strcat(subjectdir,cond {1}));
data{1,i} = ft_freqdescriptives ([], PLhann);
clear PLhann end;
ERROR: Index exceeds matrix dimensions
  2 commentaires
Ilham Hardy
Ilham Hardy le 3 Avr 2015
Please post the complete error message (do not trim the error message).
Rena Berman
Rena Berman le 17 Jan 2018
(Answers Dev) Restored edit

Connectez-vous pour commenter.

Réponses (1)

Ingrid
Ingrid le 3 Avr 2015
Modifié(e) : Ingrid le 3 Avr 2015
your array only contains four elements (first line of your code) in your loop you are trying to acces arr{i} where i goes from 1:11 this gives you the error message that the index exceeds matrix dimensions when the loop goes to i=5 because arr{5} does not exist so you have to change
for i = 1:4
OR define
arr = {'01', '02', '03', '04','05','06','07','08','09','10','11'};
depending on which one is applicable for your case

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