MATLAB: Read certain files from a directory in matlab

filenametext file

Hello,
I have over 100 .mat files in a directory and I am wondering how can I read and plot some of them. For example the file names are like such:
XX11YZ08 , XX12YZ07, XX13YZ08, XX14YZ06, XX15YZ08, and so on…
I would like to read and plot the data from all the files whose name end with '08'.
Thanks a lot in advance

Best Answer

Hi you can begin your m-file with dir() like
>_>filenames_in_mydirectory=dir()_
then create a cicle (for,while..)
in this cicle use string functions for comparing only last 2 character of the filename (before ".extension" obviously) with the string "08" and save the filenames that match with this condition in an array
after that use load()
mydata=load('myxxxyxylile08.mat'); and so plot data.
good luck