Create a table in MatLab with specific data in different spreadsheets in one Excel File.

Hello together,
I have an Excel File with 10 spreadsheets and I want to import data (always range: A2:K7) from every spreadsheet into a table in MatLab. I want to create a Loop so that the data is displayed beneath one another.
Thank you for your support!

 Respuesta aceptada

Stephan
Stephan el 19 de Oct. de 2019
Editada: Stephan el 19 de Oct. de 2019
Use the sheet option from the readtable function to loop through the single sheets. Indexing the values correctly in the table you create will let the data appear the way you want. in the given link you also find how to select the range of the Excel document.

5 comentarios

Thank you for your answer!
As I am new to MatLab I am stuck right now... I have:
filename = 'myfile.xlsx';
sheets = sheetnames (filename);
n = length(sheets);
xlRange = 'A1:K7';
data = cell(n,1);
for i = 1:n
data{i} = xlsread(filename,sheets{i}, xlRange);
end
I dont know how to go further. I want to create a table were the range A1:K2 of the choosen sheets is beneath each other.
Do you have a clue?
could you attach the excel file?
I need the years 2013-2018 for 10 Companies (A2:K7). :)
filename = 'NASDAQ Company Data.xlsx';
sheets = sheetnames(filename);
xlRange = 'A1:K7';
data = cell(numel(sheets),1);
for k = 1:numel(sheets)
data{k} = readtable(filename,'Sheet',sheets(k),'Range',xlRange,...
'PreserveVariableNames',true);
end

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 19 de Oct. de 2019

Comentada:

el 21 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by