got an error "index exceed matrix dimension"
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Wayne King
le 26 Juil 2012
Modifié(e) : Wayne King
le 26 Juil 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 commentaires
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!