MATLAB: How to use files from different folders to the script.

addpathfilepathfolders

Hi guys
my files are organised as such:
Engine\Vehicle\Date\data.csv
files for each vehicle are organised into days.
I want to be able to run my script from one location without having to copy it into each folder that I want to use it. This is for data analysis so the file names and subfolder names change regularly each day. the folder name stays the same however.
The script that I use lives in a different directory.
Currently I have been able to add the files to the script path with
addpath(genpath('Engine'))

Best Answer

Hi,
what about the following procedure:
theDates = dir('.\Engine\Vehicle');
for iDate = 1:length(theDates)
if theDates(i).isdir
data = csvread(fullfile(pwd, 'Engine', theDates(iDate).name, 'data.csv'));
end
end