Extracting particular data from excel table

1 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

更多回答(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