resample matlab实现

Posted fellow1988

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了resample matlab实现相关的知识,希望对你有一定的参考价值。

使用线性插值实现sample rate转换。

function output = simpleResample(input, inputfs, outputfs)

inputLen = length(input(:, 1));

outputLen = floor(inputLen * outputfs / inputfs);

output = zeros(outputLen, 1);

timeStep = inputfs / outputfs;

curTime = 1;

integer = 0;

frac = 0;

for i = 1:1:outputLen

  integer = floor(curTime)

  frac = curTime - floor(curTime);

  if integer + 1 < inputLen

    output(i, 1) = input(integer, 1) + frac * ( input(integer + 1, 1) - input(integer, 1));  

  end

  curTime = curTime + timeStep;

end

win = fir1(13, 0.6, ‘low‘)

output = filter(win, 1, output);

end

以上是关于resample matlab实现的主要内容,如果未能解决你的问题,请参考以下文章