How to calculate an average value in a matrix with respect to timestamps
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Eivind Sommerstad
am 10 Apr. 2023
Kommentiert: Eivind Sommerstad
am 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. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1350529/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1350529/image.png)
1 Kommentar
Walter Roberson
am 10 Apr. 2023
I recommend that you convert to timetable() objects and use retime()
Akzeptierte Antwort
Vinayak Choyyan
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!