list all the files of certain type in directory and put them in a variable

19 views (last 30 days)
How do I put all files of certain type in a directory and put them in variable
eg. if my directory has 2 images new.jpg and tell.jpg
I want in matlab
a(1)=new.jpg a(2)=tell.jpg
automatically without me having to hardcode it in..

Accepted Answer

Thomas
Thomas on 4 Jun 2012
I guess you will have more processing to do after getting all the file names in matlab. Here is a wonderful example on how to process a sequence of file sin MATLAB
else if you just want the names of jpg files in a variable
try
a=dir('*.jpg')
a(1,1).name
a(2,1).name

More Answers (0)

Categories

Find more on Search Path 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!