How to calculate an average value in a matrix with respect to timestamps
6 次查看(过去 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.
1 个评论
采纳的回答
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])
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:
- ‘timetable’ https://www.mathworks.com/help/matlab/ref/timetable.html
- ‘groupsummary’ https://www.mathworks.com/help/matlab/ref/double.groupsummary.html
- How to sum over grouped data in a table https://www.mathworks.com/matlabcentral/answers/447189-how-to-sum-over-grouped-data-in-a-table
I hope this helps resolve the issue you were facing.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!