Hello,
Can anyone help me plot this table data? I want to have the date and time as x - axis and the other variables as 6 differnent plots all in the same
figure.
Thanks,
Amir

 채택된 답변

Cris LaPierre
Cris LaPierre 2022년 3월 4일

0 개 추천

Read the table in as a table using readtable. You will want to make sure column 1 is read in as a datetime. This 'should' happen automatically, but may depend on your version of MATLAB. Once in MATLAB, you can just plot using the datetime variable as your x input. As a datetime, it will automatically show date and time.
You can use xtickformat function to modify the display format of the datetime values.
See more info here.

댓글 수: 3

This is the code that I am using:
xlsx_name = 'C:\\Air Temperature\MQLoad (1).xlsx'
tab = readtable(xlsx_name);
figure
stackedplot(tab)
This is what I get:
When I change the code to:
stackedplot(tab(:,1),tab(:,2))
I get this 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 stackedplot (line 71)
Variables to plot must be a valid data type.
Error in Preliminary_Time (line 85)
stackedplot(tab(:,1),tab(:,2))
xlsx_name = 'C:\\Air Temperature\MQLoad (1).xlsx'
tab = readtable(xlsx_name);
stackedplot(tab,'XVariable','Var1')
If that doesn't work, please share your spreadsheet. You can attach it to your post using the paperclip icon.
It's working now, thank you!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by