필터 지우기
필터 지우기

issues with sort_nat and natsortfiles; error improper matrix reference

조회 수: 3 (최근 30일)
shru s
shru s 2017년 6월 12일
편집: Stephen23 2021년 4월 18일
hello, im using the following code :
folderName = 'C:\Users\Shruthi\Desktop\project\A data\SegmentedCharacters';
Imgs = dir(fullfile(folderName, '*.jpg'));
C={Imgs.name};
cx=natsortfiles(C)
q=1;
for blah blah
Img = imread(fullfile(folderName, cx(q).name)); % Read image
q=q+1;
blah blah
end
but it gives me this error
Improper index matrix reference.
Error in Untitled5 (line 142)
Img = imread(fullfile(folderName, cx(q).name)); % Read image
could anyone tell me how i can rectify this? Thank you!

채택된 답변

Stephen23
Stephen23 2017년 6월 12일
편집: Stephen23 2021년 4월 18일
natsortfiles can now sort the DIR structure directly:
>> S = dir('*.txt');
>> S.name
ans =
'1.txt'
ans =
'10.txt'
ans =
'2.txt'
>> S = natsortfiles(S); % alphanumeric sort by filename
>> S.name
ans =
'1.txt'
ans =
'2.txt'
ans =
'10.txt'
  댓글 수: 1
shru s
shru s 2017년 6월 13일
편집: shru s 2017년 6월 13일
Thank you for writing this beautiful code! It has been very very helpful

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by