How to calculate an average value in a matrix with respect to timestamps
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Eivind Sommerstad
il 10 Apr 2023
Commentato: Eivind Sommerstad
il 13 Apr 2023
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 Commento
Risposta accettata
Vinayak Choyyan
il 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])
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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Time Series Events in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!