Reading excel file sheets

조회 수: 2 (최근 30일)
NETHRAVATHI S
NETHRAVATHI S 2021년 3월 19일
댓글: laurent jalabert 2022년 2월 4일
How to read sheets of an excel file and save it. also I want to access these sheets inside a for loop for further analysis and plottig.
I have done like this.
filename = 'timeframe_wodsm.xls';
VHC = xlsread(filename,1);
HC = xlsread(filename,2);
MC = xlsread(filename,3);
LC = xlsread(filename,4);
Here I am getting 4 different files for each sheets,
For further analysis, logic is the same but i have to repeat it for 4 times. How to keep it in a loop?
Also how to plot 4 graphs for each of the sheets inside the loop itself?
  댓글 수: 1
laurent jalabert
laurent jalabert 2022년 2월 4일
d = uigetdir(pwd, 'Select a folder');
DATA = dir(fullfile(d, '*.xlsx'));
[status,sheets] = xlsfinfo(DATA.name);
sheets = sheetnames(DATA.name);
for ii=1:length(sheets)
EachSheet{ii} = readtable(DATA.name,'Sheet',ii);
end

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

채택된 답변

KSSV
KSSV 2021년 3월 19일
편집: KSSV 2021년 3월 19일
It is suggested to use readtable instead.
filename = 'timeframe_wodsm.xls';
data = = cell(4,1) ;
for i = 1:4
data{i} = xlsread(filename,i);
end
  댓글 수: 1
NETHRAVATHI S
NETHRAVATHI S 2021년 3월 19일
Thank you for your answer.
It helped.

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

추가 답변 (0개)

카테고리

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