How do I import a column (f.e. C2:C37) of multiple Excel files into one vector in Matlab?

조회 수: 1 (최근 30일)
I am currently trying to figure out a loop, but am an absolute beginner and have difficulties to find the right commands for it.
One thing that I probably need to mention is that the column is the same for each file (hence same rows etc), but some of the columns have randomly empty cells that I would like to replace with 0.
The order of that final vector is important too.
Thanks very much in advance!
  댓글 수: 3
Beyhan Vurgun
Beyhan Vurgun 2021년 1월 11일
Thank you. Unfortunately I could not figure out how to read then just one column out of all the excel files that I successfully imported, and with those create one column vector?
dpb
dpb 2021년 1월 11일
Either use the 'Range' argument to limit the range (only works for spreadsheets) or just read the whole array and keep only what is needed--generally at least as fast if not faster than the special-case of reading only subset of a file.

댓글을 달려면 로그인하십시오.

답변 (1개)

Mathieu NOE
Mathieu NOE 2021년 1월 11일
hello
this is a simple code to load multiple excel (one sheet) data
you can build your solution on this example
file_list = dir('*.xlsx'); % list all xlsx files in current directory
for i = 1:length(file_list)
filename = file_list(i).name;
data_in{i} = xlsread(filename,range); % stores the filename data in array of cells
% insert your code here
end

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by