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

1 visualización (últimos 30 días)
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 comentarios
Beyhan Vurgun
Beyhan Vurgun el 11 de En. de 2021
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 el 11 de En. de 2021
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.

Iniciar sesión para comentar.

Respuestas (1)

Mathieu NOE
Mathieu NOE el 11 de En. de 2021
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

Community Treasure Hunt

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

Start Hunting!

Translated by