Borrar filtros
Borrar filtros

issues with sort_nat and natsortfiles; error improper matrix reference

3 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Stephen23
Stephen23 el 12 de Jun. de 2017
Editada: Stephen23 el 18 de Abr. de 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 comentario
shru s
shru s el 13 de Jun. de 2017
Editada: shru s el 13 de Jun. de 2017
Thank you for writing this beautiful code! It has been very very helpful

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by