MATLAB: Import data of a sequence of files and process the data

importing excel dataMATLABmultiple files

I have a sequence of files that I want to process the data in one file with the same task. But when I import data to assign to a new array it failed:
'Error using importdata (line 136)
Unable to open file.
Error in freq (line 10)
mydata{k} = importdata(file_name{k})'.
I just want to work with one column of the file like in the picture. Thanks for your help!
clear all;
source_dir = uigetdir([]);
extension = '.csv'
csvFiles = dir('*.csv');
num = length(csvFiles);
file_name = cell(1,num);
mydata = cell(1,num)
for k=1:num;
file_name{k} = fullfile(source_dir,['\SYSTEM',num2str(k),extension]);
mydata{k} = importdata(file_name{k})
end

Best Answer

source_dir = uigetdir([]);
extension = '.csv'
csvFiles = dir( fullfile(source_dir, '*.csv') );
num = length(csvFiles);
file_name = fullfile( source_dir, csvFiles );
mydata = cell(1,num)
for k=1:num;
mydata{k} = importdata(file_name{k})
end