Remove elements from vector to change the sampling rate

조회 수: 2 (최근 30일)
marcusbarnet
marcusbarnet 2018년 1월 2일
댓글: marcusbarnet 2018년 1월 10일
Hi to all,
I have a vector " imu" with a size of 11497 elements. These elements are samples captured at a very high rate (the total time is 71 seconds so I think the frequency is about 160 Hz). Since I acquired all the other values at 10Hz, the size of all my other vectors is 719.
I would like to remove the oversampled elements from the vector " imu" in order to have only 10 samples per second.
Is there any way to do this? Can you help me, please?
  댓글 수: 2
Gaurav Ahuja
Gaurav Ahuja 2018년 1월 9일
Could you provide more clarification on this:- 1.) do you wish to make an application that would achieve this? 2.) or do you already have "imu" vector and now wish to get the required data?
For the 1st case, you would need to write a custom logic for doing so. If you are using Simulink, you could use rate transition block to achieve something like this.
For 2nd case, write a custom logic to store the 'n'th element into another vector. Refer the following code for a better understanding.
if true
a = magic(4)
b = a(1:16) % this vector is similar to "imu"
c=b(4:4:16) % accepting every 4th elecment.
end
Hope this helps.
marcusbarnet
marcusbarnet 2018년 1월 10일
Thank you, Gaurav! It was the second case and your solution worked fine for me!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by