Filter löschen
Filter löschen

Extracting particular data from excel table

2 Ansichten (letzte 30 Tage)
Indrani
Indrani am 14 Jun. 2023
Kommentiert: Indrani am 15 Jun. 2023
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 Kommentare
Indrani
Indrani am 14 Jun. 2023
Thank you.
But how do I do it for the attached csv file?
Dyuman Joshi
Dyuman Joshi am 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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sharad
Sharad am 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 Kommentare
Sharad
Sharad am 15 Jun. 2023
Thanks for the approach
Indrani
Indrani am 15 Jun. 2023
Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by