MATLAB: How to import from a csv with a different file name

csvfileimportMATLABname

Hi guys!
I need to import a different data's from a lot of csv. In this example is about frews.csv. Every file has a different name, and i don't want to change every time the file name.
filename = 'C:\Users\Jhon\Desktop\MATLAB\frews.csv';
delimiter = ',';
formatSpec = '%*s%f%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'ReturnOnError', false);
fclose(fileID);
frews = [dataArray{1:end-1}];
clearvars filename delimiter formatSpec fileID dataArray ans;
% thanks for your help.

Best Answer

https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html See the last example to read multiple files with different names using dir()