Index exceeds matrix dimensions error?

2 views (last 30 days)
matlab12345
matlab12345 on 24 Jun 2013
What is the problem? Here is my code:
dirs = {'pos1','pos2','pos3'};
groups = {'unflashed','flashed_1xsett3','flashed_1xsett3_15sec','flashed_1xsett5','flashed_1xsett5_15sec','flashed_2xsett5','flashed_2xsett5_15sec'};
groups_bin = {'0', '1', '2','3','4','5','6','7'};
fprintf('%s\n',['Reading ' base_path]);
for d = 1 : length(dirs)
fprintf('%s',['\' dirs{d}]);
for g = 1 : length(groups);
fprintf('%s',['\' groups{g}]);
for f = 1 : 1
for led = 1 : 9
fname = ['imageL' num2str(led) '_' num2str(f-1) '.png'];
fprintf('%s',['\' fname]);
try
img{d, g, f, led} = imread(fullfile(base_path,person,dirs{d},groups{g},fname));
catch
img{d,g,f,led}=[];
end
fprintf(repmat('\b',1,length(fname)+1));
end
end
fprintf(repmat('\b',1,length(groups{g})+1));
end
fprintf(repmat('\b',1,length(dirs{g})+1));
end
fprintf('\n');

Answers (4)

Maria Perdomo
Maria Perdomo on 24 Jun 2013
Edited: Maria Perdomo on 24 Jun 2013
the line problem is 3 lines before the end:
fprintf(repmat('\b',1,length(dirs{g})+1));
dirs has just 3 elements, but g reaches up to 7:
for g = 1 : length(groups);

matlab12345
matlab12345 on 24 Jun 2013
Edited: matlab12345 on 24 Jun 2013
how should i change it? thank you for your help :)

matlab12345
matlab12345 on 24 Jun 2013
oh ok, i should write dirs{d}? right?
  1 Comment
Jan
Jan on 24 Jun 2013
Edited: Jan on 24 Jun 2013
Please post comments in the comments section and not as answer. Thanks.
And yes, dirs{d} looks better.

Sign in to comment.


matlab12345
matlab12345 on 24 Jun 2013
thank you :)

Community Treasure Hunt

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

Start Hunting!