Index exceeds matrix dimensions error?

1 Ansicht (letzte 30 Tage)
matlab12345
matlab12345 am 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');

Antworten (4)

Maria Perdomo
Maria Perdomo am 24 Jun. 2013
Bearbeitet: Maria Perdomo am 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 am 24 Jun. 2013
Bearbeitet: matlab12345 am 24 Jun. 2013
how should i change it? thank you for your help :)

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

Melden Sie sich an, um zu kommentieren.


matlab12345
matlab12345 am 24 Jun. 2013
thank you :)

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