Clear Filters
Clear Filters

How to calculate an average value in a matrix with respect to timestamps

6 views (last 30 days)
Hello, i have a "mixed Rinex observation" file that i have read into matlab with the "rinexread()" function. What i want to do is "group" the "SIC" values by the "Time" values so that for example all the values for SIC in the timestamp 13:49:10 gets added together, averaged out and then saved to a new matrix. I want this to happen for every "new" timestamp going down this file. For clarification, this is for the GPS part of the observation file.

Accepted Answer

Vinayak Choyyan
Vinayak Choyyan on 12 Apr 2023
Hi Eivind,
As per my understanding, you would like to sum ‘S1C’ data after grouping it by time.
Please check out the below example.
filename = "GODS00USA_R_20211750000_01H_30S_MO.rnx";
data = rinexread(filename);
tmp=data.GPS(:,9);
tmp=groupsummary(tmp,'Time','sum');
output=tmp(:,[1 3])
output = 120×2 table
Time sum_S1C ____________________ _______ 24-Jun-2021 00:00:00 433 24-Jun-2021 00:00:30 431.75 24-Jun-2021 00:01:00 431.25 24-Jun-2021 00:01:30 436.5 24-Jun-2021 00:02:00 435.5 24-Jun-2021 00:02:30 433 24-Jun-2021 00:03:00 435.75 24-Jun-2021 00:03:30 432.25 24-Jun-2021 00:04:00 433.5 24-Jun-2021 00:04:30 435.75 24-Jun-2021 00:05:00 438.25 24-Jun-2021 00:05:30 436.5 24-Jun-2021 00:06:00 437.75 24-Jun-2021 00:06:30 437.75 24-Jun-2021 00:07:00 437.25 24-Jun-2021 00:07:30 435.25
Since ‘data.GPS’ is of type ‘timetable’, we can use the ‘groupsummary’ function to find the sum of data after grouping it by column ‘Time’.
Note: In the above code, ‘S1C’ is the 9th column in ‘data.GPS’. The file "GODS00USA_R_20211750000_01H_30S_MO.rnx" is included with MATLAB and you can directly access it like I did in the above example.
For more details, please visit these documentation pages:
I hope this helps resolve the issue you were facing.
  1 Comment
Eivind Sommerstad
Eivind Sommerstad on 13 Apr 2023
Thank you for your answer, after some time i managed to find a way to make it work on my own. Wether it is a good way or not im not so sure about but it works for what i need it to do.
Here is a part of the code i wrote. It just repeats for the other variables defined at the start.
At the very end of the script i plot the data.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!