what should I include in the code that read the data from specific sheet of excel file

조회 수: 2 (최근 30일)
Hi,
I have excel file with around 12 sheet basically 12 experimental data and I would like to make my life easier by putting the line of code into the existing code that it will read the sheet name and plot the data from that sheet, with code below it is only reading the data from the first sheet..... I am googling from last hour but I couldnt't find something relevant coming. It be a great time saving help if you guys can help.
Current code:
a=readmatrix('Head_Pressure_all.ods');
% I want to add a sort of code line here where the code can into file 'Head_Pressure_all.ods' and read the data from that sheet
x=a(:,4);
y=a(:,8);
figure(1)
plot(x,y,'x','LineWidth',0.5);
hold on

채택된 답변

KSSV
KSSV 2021년 7월 22일
T = readtable('myfile.xlsx','Sheet','1');
  댓글 수: 1
muhammad choudhry
muhammad choudhry 2021년 7월 22일
hi, thanks for help...... I got it sorted your line works but with readmatrix, getting the error below by using readtable.
Error:
Warning: Column headers from the file were modified to make them valid MATLAB identifiers
before creating variable names for the table. The original column headers are saved in the
VariableDescriptions property.
Set 'PreserveVariableNames' to true to use the original column headers as table variable
names.
Error using tabular/plot (line 216)
Tables and timetables do not have a plot method. To plot a table or a timetable, use the
stackedplot function. As an alternative, extract table or timetable variables using dot or
brace subscripting, and then pass the variables as input arguments to the plot function.
Error in pressure_head_all (line 7)
plot(x,y,'x','LineWidth',0.5);

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

추가 답변 (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