Index exceeds matrix dimensions

2 Ansichten (letzte 30 Tage)
venuuu
venuuu am 3 Apr. 2015
Kommentiert: Rena Berman am 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 Kommentare
Ilham Hardy
Ilham Hardy am 3 Apr. 2015
Please post the complete error message (do not trim the error message).
Rena Berman
Rena Berman am 17 Jan. 2018
(Answers Dev) Restored edit

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ingrid
Ingrid am 3 Apr. 2015
Bearbeitet: Ingrid am 3 Apr. 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

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by