got an error "index exceed matrix dimension"
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
here sir iwant to read all my file 1224 numbers. But it just read & process only 13 number file then it said " index exceed matrix dimension".... plz help.here i used this following code
workingDir='E:\ flame 1 (500 fps)\';
imageNames = dir(fullfile(workingDir,'*.jpg'));
imageNames = {imageNames.name}';
imageStrings = regexp([imageNames{:}],'(\d*)','match');
imageNumbers = str2double(imageStrings);
[~,sortedIndices] = sort(imageNumbers);
sortedImageNames = imageNames('sortedIndices');
fileID = fopen('img_fstd2.dat','w');
for ii = 1:13%length(sortedImageNames)
I1 = imread(fullfile(workingDir,sortedImageNames{ii}));
for i=1:530
for j=1:380
if I1(i,j)<60
I1(i,j)=0;
elseif I1(i,j)>90
I1(i,j)=1;
end
end
end
0 Kommentare
Antworten (1)
Wayne King
am 26 Jul. 2012
Bearbeitet: Wayne King
am 26 Jul. 2012
I think you should determine where the error is occurring. In other words, if you remove this for loop:
for i=1:530
for j=1:380
if I1(i,j)<60
I1(i,j)=0;
elseif I1(i,j)>90
I1(i,j)=1;
end
end
Do you still get the error only running:
workingDir='E:\ flame 1 (500 fps)\';
imageNames = dir(fullfile(workingDir,'*.jpg'));
imageNames = {imageNames.name}';
imageStrings = regexp([imageNames{:}],'(\d*)','match');
imageNumbers = str2double(imageStrings);
[~,sortedIndices] = sort(imageNumbers);
sortedImageNames = imageNames('sortedIndices');
fileID = fopen('img_fstd2.dat','w');
for ii = 1:13%length(sortedImageNames)
I1 = imread(fullfile(workingDir,sortedImageNames{ii}));
end
Also, I don't think you need that complicated for loop:
for i=1:530
for j=1:380
if I1(i,j)<60
I1(i,j)=0;
elseif I1(i,j)>90
I1(i,j)=1;
end
end
How about just:
Il(Il<60) = 0;
Il(Il>90) = 1;
0 Kommentare
Siehe auch
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!