Extracting particular data from excel table

1 view (last 30 days)
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 Comments
Indrani
Indrani on 14 Jun 2023
Thank you.
But how do I do it for the attached csv file?
Dyuman Joshi
Dyuman Joshi on 14 Jun 2023
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

Sign in to comment.

Accepted Answer

Sharad
Sharad on 14 Jun 2023
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 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!