フィルターのクリア

Decimate to a specific number

12 ビュー (過去 30 日間)
youngz
youngz 2017 年 4 月 22 日
回答済み: Walter Roberson 2017 年 4 月 22 日
Hi,
I have a signal and I would like to downsample it at a specific number (e.g. 256). I am thinking to use the function decimate(), anyway, it accepts only the integers as input. So, I cannot downsample my signal to a specific value.
The code:
myArray = 1:980;
target = 256;
[p,q] = rat(256/length(myArray));
y = decimate(myArray,p/q);
My first idea is to interpolate the data in order to reach a multiple of my target sample rate. Anyway, maybe there is a different (and better) solution.
NB: I know that there is the function resample(), anyway I am trying to find new solutions.
Regards

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 4 月 22 日
myArray = 1:980;
target = 256;
n_ent = length(myArray);
y = interp1( 1:n_ent, myArray, linspace(1, n_ent, target) );
You cannot use decimate() the way you had hoped to.

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by