MATLAB Answers


how to get folder name

Asked by Elysi Cochin on 26 Oct 2013
Latest activity Answered by Walter Roberson
on 26 Oct 2013

i have 4 folders named

    1 - airplane
    2 - baseball
    3 - beach
    4 - forest

now on calculation if i get value 2, i want to access all images in folder "2 - baseball"

i'm not getting the access correct... please do correct it for me...

    BaseFileName = sprintf('%d*\\image_44', i);
    FullFileName = fullfile('Training Dataset', BaseFileName);
    imageFile = imread(FullFileName);

the error i get is

     ??? Error using ==> dicomread>newDicomread at 175
    File "Training Dataset\6*\image_44" not found.

how to read that folder name.... please do reply.....



No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 26 Oct 2013
 Accepted answer

folders = { '1 - airplane'
  '2 - baseball'
  '3 - beach'
  '4 - forest' }
FullFileName = fullfile('Training Dataset', folders{i}, 'image_44.jpg');

See also


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!