How to import information from an excel file with many spreadsheets

1 次查看(过去 30 天)
Hi, I am very new using Matlab I need to do the next:
  1. Import two columns from a multiple datasheets from one excel file, i need a specific range A2:B7804
  2. To plot this information, there are to variables Time and signal
  3. To save these plots
There are 24 sheets in each excel file, I read about to use readtable and xlsread but I tried to do a loop to import data but I can't understand how to save the information from each sheet, and then plot, I can imagine that I have to save each couple of columns in a group of tables but I don't know how to do it
Thanks for your help, It is very important for me this blow my mind :(
num_sheets = 24;
for i=1:num_sheets
data = readtable('CONSOLIDADO M50.xlsx', 'Sheet', i,'Range','A2:B7804');
end
  1 个评论
Maria Cuellar
Maria Cuellar 2022-4-29
Hi thanks I tried to extract from each cell the information of the two rows with
for i=1:length(data)
M = data{i}
end
I can see the data but I can't store it or extract it I need to graph Value vs Time but I don't be able to do it yet
Sorry for the mess
Thanks

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2022-4-29
The ‘data’ output needs to be saved as a cell array for each value of ‘i’.
Try something like this —
num_sheets = 24;
for i=1:num_sheets
data{i} = readtable('CONSOLIDADO M50.xlsx', 'Sheet', i,'Range','A2:B7804');
end
See the documentation section on Access Data in Cell Array for more information on how to work with them.
See the documentation on the plot function for that information.
.
  1 个评论
Star Strider
Star Strider 2022-4-29
The reference:
M = data{i}
should display the relevant information from that sheet of the Excel file.
You can then use the appropriate columns of ‘M’ to do the plot.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by