Index exceeds matrix dimensions
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Ingrid
on 3 Apr 2015
Edited: Ingrid
on 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
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!