Downsampling array data from counts per minute to counts per hour
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
dormant
el 23 de Oct. de 2024
Respondida: Harsh
el 24 de Oct. de 2024
I have an evenly sampled array of data, say chickensPerMinute.
I want to downsample this by a factor of 60 to return chickensPerHour.
Is there a MATLAB function to do this, akin to the downsample function which returns mean values for each downsampling window.
0 comentarios
Respuesta aceptada
Star Strider
el 23 de Oct. de 2024
2 comentarios
Star Strider
el 24 de Oct. de 2024
As always, my pleasure!
The retime function is extremely useful for this and other operations. Another is the synchronize function.
Más respuestas (3)
ScottB
el 23 de Oct. de 2024
if A represents chickensPerMinute then
B = A(1:60:end); should downsample to chickensPerHour just by indexing.
Harsh
el 24 de Oct. de 2024
Hi dormant,
There can be multiple ways to downsample your data depending on the initial data type. But if your input is just an evenly sampled array you can use the “reshape” and “mean” functions in MATLAB to achieve your desired result. Below is an example code that illustrates how to do so:
% An array containing chicken values for 120 minutes
chickensPerMinute = randi([1 10],1,120)
% each column in reshaped array corresponds to chickens in the respective hour
reshapedArr = reshape(chickensPerMinute,60,[])
% taking mean in column direction gives the avg chickens per hour
chickensPerHour = mean(reshapedArr,1)
You can look at the following documentation link to understand how “reshape” function works - https://www.mathworks.com/help/matlab/ref/double.reshape.html
0 comentarios
Ver también
Categorías
Más información sobre Multirate Signal Processing 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!