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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Beyhan Vurgun
Beyhan Vurgun il 11 Gen 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 il 11 Gen 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.

Accedi per commentare.

Risposte (1)

Mathieu NOE
Mathieu NOE il 11 Gen 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