码迷,mamicode.com
首页 > 其他好文 > 详细

resample matlab实现

时间:2018-11-04 22:58:48      阅读:555      评论:0      收藏:0      [点我收藏+]

标签:rac   function   res   tfs   out   tput   NPU   matlab实现   mes   

使用线性插值实现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实现

标签:rac   function   res   tfs   out   tput   NPU   matlab实现   mes   

原文地址:https://www.cnblogs.com/fellow1988/p/9906171.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!