Single Excel (.xslx) with multiple sheets need to plot some columnes.

조회 수: 2 (최근 30일)
Harr
Harr 2020년 10월 28일
편집: Harr 2023년 1월 2일
Dear i have an .xslx file with 30 different sheets. From Sheet 3 to 30 i want to return 2 plots per sheet.
Excelfile name is: TEST12_St.xlsx
Name of the sheet number 3 is: Test12_1
Name of the sheet number 4 is: Test12_2
.
.
Name of the sheet number 30 is: Test12_28
Plot information:
x_axis: represents time in seconds and always in the B columne for the sheets (3 to 30). ploting should start from cell number 18 (ends differently at differnt sheets).
y_axis for Plot 1: is column D also from cell number 18
y_axis for Plot 2: is column E and F (need to be in different colors)
Please see the attached simplified Exce file.
I tried to start with the following code but I failed (Note: I am trying to learn and use Matlab to make my works easier)
% This one only read two columnes in Test sheet Test12_1
T=xlsread('TEST12_St.xlsx','Test12_1')
B=T(:,2);
[Y, M, D, H, MN, S] = datevec(B);
H*3600+MN*60+S
B=ans;
D=T(:,3);
figure
h = plot(B,D)

채택된 답변

drummer
drummer 2020년 11월 1일
편집: drummer 2020년 11월 2일
I encourage you to use readtable rather than xlsread. You can always use the importTool as well.
However, readtable is for a single spreadsheet. You'd do it for every single sheet you wanna read.
Instead, try spreadSheetDatastore, then you can access all of your sheets at once.
Afterwards, you can play with the variable names (columns) in the data you wanna extract.
Cheers

추가 답변 (1개)

Sunil Patidar
Sunil Patidar 2020년 11월 2일
편집: Sunil Patidar 2020년 11월 3일
Hi,
You can use xlsinfo function to read the file. Then, use xlsread function to read the content of the sheet.
refer to the following MATLAB Answeres link for more details:
  댓글 수: 2
Harr
Harr 2020년 11월 2일
편집: Harr 2023년 1월 2일
Dear drummer and Sunil Patidar, thank you very much for your replies!
Peter Perkins
Peter Perkins 2020년 11월 20일
drummer is correct. Strongly prefer readtable (or readmatrix) over xlsread. xlsread is old and far less capable than readtable.

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

카테고리

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