Importing multiple excel sheet's data into individual variables
이전 댓글 표시
Very similar to this question, I want to import multiple columns from multiple excel sheets and create a column vector with a name based on the input file. What I've managed to do so far is import all of one variable from all sheets into one array, but I want them separately.
source_dir ='E:\xxxx'
source_files = dir(fullfile(source_dir,'*.csv'));
for k=1:length(source_files)
d{k} = xlsread(fullfile(source_dir,source_files(k).name), 'A:A'); %distance upstream
e{k} = xlsread(fullfile(source_dir,source_files(k).name), 'D:D'); %elevation upstream
x{k} = xlsread(fullfile(source_dir,source_files(k).name), 'B:B'); %x co-ord
y{k} = xlsread(fullfile(source_dir,source_files(k).name), 'C:C'); %y co-ord
a{k} = xlsread(fullfile(source_dir,source_files(k).name), 'E:E'); %upstream area
s{k} = xlsread(fullfile(source_dir,source_files(k).name), 'F:F'); %local slope
end
I'd want outputs of d111, e111, x111 etc, where 111 is the file name.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!