필터 지우기
필터 지우기

how to plot from CSV files?

조회 수: 3 (최근 30일)
Lilya
Lilya 2024년 5월 19일
댓글: Star Strider 2024년 5월 20일
Hi all,
I have some data as CSV and want to plot the time (col. 1,2) in x-axis with temperature (col. 3) in y-axis (screenshot)
how to :
  • access the data
  • plot the data
thanks!!

채택된 답변

Star Strider
Star Strider 2024년 5월 19일
It would help to have your data rather than an image of it.
In the interim, try something like this —
imshow(imread('Screen Shot 20....42.20 PM.png'))
% T1 = readtable('YourFile.csv')
T1 = table(['16/02/2024';'16/02/2024'], ["11:37:39AM"; "11:37:40AM"], [11.9420; 11.9440], 'VariableNames',{'LogInterval','VarName2','VarName3'})
T1 = 2x3 table
LogInterval VarName2 VarName3 ___________ ____________ ________ 16/02/2024 "11:37:39AM" 11.942 16/02/2024 "11:37:40AM" 11.944
LogTime = datetime(T1.LogInterval, 'InputFormat','dd/MM/yyyy') + timeofday(datetime(T1.VarName2, 'InputFormat','hh:mm:ssa'))
LogTime = 2x1 datetime array
16-Feb-2024 11:37:39 16-Feb-2024 11:37:40
LogTime.Format = 'yyyy/MM/dd HH:mm:ss'
LogTime = 2x1 datetime array
2024/02/16 11:37:39 2024/02/16 11:37:40
T1 = addvars(T1, LogTime, 'Before',1)
T1 = 2x4 table
LogTime LogInterval VarName2 VarName3 ___________________ ___________ ____________ ________ 2024/02/16 11:37:39 16/02/2024 "11:37:39AM" 11.942 2024/02/16 11:37:40 16/02/2024 "11:37:40AM" 11.944
T1 = removevars(T1,[2 3])
T1 = 2x2 table
LogTime VarName3 ___________________ ________ 2024/02/16 11:37:39 11.942 2024/02/16 11:37:40 11.944
VN = T1.Properties.VariableNames;
figure
plot(T1.LogTime, T1.VarName3)
grid
xlabel(VN{1})
ylabel(VN{2})
That should work.
.
  댓글 수: 2
Lilya
Lilya 2024년 5월 20일
thank you very much!! it works
Star Strider
Star Strider 2024년 5월 20일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by