MATLAB: How to read datafiles residing in a different path than the program using the ‘load’ command or otherwise

faqfile readingswitching path

My matlab code wherein I read the datafiles (filename format: datafile_XX.dat, XX is the serial number of the file) using the 'load' command sits in the directory D:/, while my datafiles reside in the path F:/TP/Data/day. How to make my program read the datafiles (in a loop) sitting in a different path using the load command (or there is any other convenient command that helps)?

Best Answer

Use fullfile() and dir().