How to calculate an average value in a matrix with respect to timestamps
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Eivind Sommerstad
el 10 de Abr. de 2023
Comentada: Eivind Sommerstad
el 13 de Abr. de 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 comentario
Walter Roberson
el 10 de Abr. de 2023
I recommend that you convert to timetable() objects and use retime()
Respuesta aceptada
Vinayak Choyyan
el 12 de Abr. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!