Azzera filtri
Azzera filtri

issues with sort_nat and natsortfiles; error improper matrix reference

3 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Stephen23
Stephen23 il 12 Giu 2017
Modificato: Stephen23 il 18 Apr 2021
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 Commento
shru s
shru s il 13 Giu 2017
Modificato: shru s il 13 Giu 2017
Thank you for writing this beautiful code! It has been very very helpful

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Read, Write, and Modify Image 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