Index exceeds matrix dimensions error?

1 次查看(过去 30 天)
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');

回答(4 个)

Maria Perdomo
Maria Perdomo 2013-6-24
编辑:Maria Perdomo 2013-6-24
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 2013-6-24
编辑:matlab12345 2013-6-24
how should i change it? thank you for your help :)

matlab12345
matlab12345 2013-6-24
oh ok, i should write dirs{d}? right?
  1 个评论
Jan
Jan 2013-6-24
编辑:Jan 2013-6-24
Please post comments in the comments section and not as answer. Thanks.
And yes, dirs{d} looks better.

请先登录,再进行评论。


matlab12345
matlab12345 2013-6-24
thank you :)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by