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

조회 수: 3 (최근 30일)
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.

채택된 답변

Vinayak Choyyan
Vinayak Choyyan 2023년 4월 12일
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
Eivind Sommerstad
Eivind Sommerstad 2023년 4월 13일
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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by