got an error "index exceed matrix dimension"
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Wayne King
on 26 Jul 2012
Edited: Wayne King
on 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 Comments
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!