Azzera filtri
Azzera filtri

got an error "index exceed matrix dimension"

1 visualizzazione (ultimi 30 giorni)
saras
saras il 26 Lug 2012
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

Risposte (1)

Wayne King
Wayne King il 26 Lug 2012
Modificato: Wayne King il 26 Lug 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;

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by