Extracting particular data from excel table

조회 수: 1 (최근 30일)
Indrani
Indrani 2023년 6월 14일
댓글: Indrani 2023년 6월 15일
I have a .csv file, which I have imported as a table in matlab. The table has freuency values for each minute of the day for the entire 24 hours. I want to analyse the data by studying each hour separately and plotting a graph for each hour. How can extract such data?
  댓글 수: 3
Indrani
Indrani 2023년 6월 14일
Thank you.
But how do I do it for the attached csv file?
Dyuman Joshi
Dyuman Joshi 2023년 6월 14일
You can import the data by readcell and then reshape it accordingly to do analysis.
It seems like the data is for every milisecond, so 00:00.0 to 59:59.9 is an hour, and the data from B2-B36001 (i.e. 36000 miliseconds in an hour) is to be analaysed and B36002-B72001, B72002-B108001 and ..., so on.
So you can use
reshape(data,36000,[])
to get the output as data for each hour in each column. Then you can use functions on the 2nd dimension of the array to directly get result.
Also, there seems to be some missing data in the file. As the number of rows is not a multiple of 36000

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

채택된 답변

Sharad
Sharad 2023년 6월 14일
Hi,
In order to analyze the data by extracting and plotting the data for each hour, you can follow these steps:
  • Load the .csv file (assuming the .csv file is present in the same directory as the script).
table = readtable('2023-01-12.csv');
  • Seperate the Time and Value columns.
time = table.Time;
value = table.Value;
  • Iterate for each hour, find the set of indices satisfying the value of each hour, and plot each of them in a seperate subplot.
% Repeat for each hour
for h=0:23
subplot(4, 6, h+1);
% Extract hour wise data
idx = find(hour(time)==h);
% plot each hour data on seperate subplot
plot(value(idx));
title(sprintf('Hour %d', h));
end
  • The output will look something like this:
  댓글 수: 3
Sharad
Sharad 2023년 6월 15일
Thanks for the approach
Indrani
Indrani 2023년 6월 15일
Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile 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