Downsampling array data from counts per minute to counts per hour
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
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
채택된 답변
  Star Strider
      
      
 2024년 10월 23일
        댓글 수: 2
  Star Strider
      
      
 2024년 10월 24일
				As always, my pleasure!  
The retime function is extremely useful for this and other operations.  Another is the synchronize function.  
추가 답변 (3개)
  ScottB
      
 2024년 10월 23일
        if A represents chickensPerMinute then 
B = A(1:60:end); should downsample to chickensPerHour just by indexing. 
  Harsh
 2024년 10월 24일
        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
참고 항목
카테고리
				Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




