MATLAB: Retrieve data from Hard Drive (Local Directory) data import How can I build my own m file to retrieve the data from my hard drive. Best Answer I would think that you need to use the dir command. If the files are located in your C drive then:clear allTopFolder = 'C:\';SubFolder = dir(TopFolder);SubFolder = SubFolder(3:end); % the first two here are just pointersa = struct2cell(SubFolder);Name = a(1,:);This will give you the name of the files where your data is located. You then need to obtain the name of each of the files in that folder:b = cellfun(@(x)dir(fullfile(TopFolder,x)),Name,'un',0);c = cellfun(@(x)x(3:end),b,'un',0);d = cellfun(@(x)struct2cell(x),c,'un',0);FileS = cellfun(@(x)x(1,:),d,'un',0);You can then import the data using one of the built in matlab functions:http://www.mathworks.co.uk/help/techdoc/ref/importdata.htmlIf your data is stored in a text file I would recommend using textscan. Related SolutionsMATLAB: Fullfile to contain multiply file extension Try:filePatternCSV = fullfile(handles.sourceFolder, '*.csv'); csvFiles = dir(filePatternCSV); filePatternXLS = fullfile(handles.sourceFolder, '*.xls'); xlsFiles = dir(filePatternXLS);filePatternODS = fullfile(handles.sourceFolder, '*.ods'); odsFiles = dir(filePatternODS);allFiles= vertcat(csvFiles,xlsFiles,odsFiles); MATLAB: Vectorizing a script with cellfun data = arrayfyn(@(ii)cellfun(@(x)dlmread(fullfile(main_folder,Name1{ii},x)),FilesToRead{ii},'un',0),1:length(FilesToRead),'un',0); Related QuestionHow to delete a .csv in the directoryHow to skip (iteration) empty folders and empty text filesHow to import a txt file from a subfolders (not included in path)Re-naming Text files in many folders using matlabOmitting pointers when listing folder contentsHow to sort files into different folders
Best Answer