matlab resample上采样,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
使用sinc window实现sample rate转换,可能sinc window 没有设计好,效果不是很好。
function ouput = myResample( input, inputfs, outputfs)
inputLen = length(input(:, 1));
outputLen = floor(inputLen * outputfs / inputfs);
output = zeros(outputLen, 1);
timeStep = inputfs / outputfs;
factor = outputfs / inputfs;
L = 8;%entries per zero-crossing
Nz = 7;%number of zero-crossing
winLen = 2 * L * Nz + 1;
filterInt = 4;
filterLen = floor(winLen / filterInt);
%generate sinc window function
for i = ceil(-winLen/2) :1 : floor(winLen/2)
winIdx = i + floor(winLen/2) + 1;
tmp = pi * double(i) / L;
if i == 0
win(winIdx) = 1;
else
win(winIdx = sin(tmp)/tmp;
end
end
win = win * 0.6;
%add delay before input
delaySample = floor(filterLen / 2);
delayInput = zeros(inputLen + delaySample, 1);
delayInput(delaySample + 1 : inputLen + delaySample, 1) = input(:, 1);
curTime = 1;
t = 1;
pos = 1;
for t = 1:1:outputLen
integer = floor(curTime)
frac = curTime - floor(curTime);
filtOfsset = floor(frac * filterInt);
if integer + filtLen - 1 < inputLen + delaySample
pos = integer;
winStart = floor(winLen / 2 - filterInt * filterLen / 2) - 1;
winEnd = floor(winLen /2 + filterInt * filterLen / 2);
%filter by sinc window
for j = winStart : 1 : winEnd
if j - filtOffset < 1
winCoeff = 0;
else
winCoeff = win(j - filtOffset);
end
output(t, 1) = output(t, 1) + winCoeff * delayInput(pos, 1);
pos = pos + 1;
end
end
curTime = curTime + timeStep;
end
end
matlab resample上采样,resample matlab实现相关推荐
- matlab图上输入希腊字母,Matlab中给图形添加【希腊字母】
比如画一条蓝色的x号线 plot(x,y,'bg') 画图: 线形:-实线-. 点划线--长虚线:短虚线 符号颜色符号线形 b 蓝. 点 c 青.圈 g 绿××标记 k 黑-实线 m 紫红* 星号 r ...
- MATLAB无穷大上的反常积分
MATLAB无穷大上的反常积分 MATLAB代码一样可以计算反常积分: syms x f; f=log(x) / x^2; e=ezplot(f,[1,10]); set(e,'Color','r', ...
- matlab音频信号处理实验报告,matlab音频信号处理实验报告.docx
matlab音频信号处理实验报告 MATLAB音频信号处理实验 南昌航空大学信息工程学院 课程实验报告 实验名称:实验时间:2014年4月23日 指导教师: 班级: 学号: 姓名: 成绩: 南昌航空大 ...
- matlab 电力电子元件对应名称,MATLAB在电力电子技术的应用
[摘要]结合电力电子技术教学中对电路波形分析上存在的问题,本文介绍了利用MATLA仿真软件中的SimPowerSystem电力系统库完成对单相桥式可控整流电路的仿真,加深同学生对本课程理论知识的理解, ...
- matlab resample,如何重新采样时间矢量数据matlab(How to resample time vector data matlab)
如何重新采样时间矢量数据matlab(How to resample time vector data matlab) 我必须重新采样以下单元格数组: dateS = '2004-09-02 06:0 ...
- matlab 信号与系统(一)—— 上采样(Upsampling)和下采样(Downsampling)
我们使用因子 p=2p=2,对一维信号 x<script type="math/tex" id="MathJax-Element-49">x< ...
- 【 MATLAB 】MATLAB 实现模拟信号采样后的重建(一)
为了让MATLAB数字信号处理的相关博文能够得到一个梳理,我开通了一个专栏:数字信号处理的MATLAB实现 模拟信号经过采样后得到x(n),从x(n)中重建模拟信号在数学上可用公式来描述: 式中, 是 ...
- 连续函数matlab采样,基于 MATLAB 的时域信号采样及频谱分析(转)
一.课程设计题目: 基于 MATLAB 的时域信号采样及频谱分析 二.基本要求: ① 掌握数字信号处理的基本概念.基本理论和基本方法: ② 学会 MATLAB 的使用,掌握 MATLAB 的程序设计方 ...
- matlab时域信号如何分析方法,信号时域采样频谱分析(matlab)
<信号时域采样频谱分析(matlab)>由会员分享,可在线阅读,更多相关<信号时域采样频谱分析(matlab)(12页珍藏版)>请在读根文库上搜索. 1.基于matlab的时域 ...
最新文章
- Java从基础进阶到高手
- Mini音乐播放器【简单版】(附源码)
- 玩转android studio,玩转AndroidStudioIDE
- 苹果是c语言安卓是什么语言,主流app是用什么语言开发的苹果和安卓的主流开...
- lm opencv 算法_相机模型与标定(七)--LM算法在相机标定中的使用
- Maven - 依赖冲突
- 国科大李保滨矩阵分析与应用2021回忆版
- jquery weui 显示loading
- C语言程序设计圆周率,如何设计C语言程序输出圆周率小数点后的1000位?请大侠出手啊。...
- pr下载与安装(含安装包百度网盘链接)
- Power BI 简介
- icp许可证怎么申请
- ANSYS预紧力螺栓连接结构(—HyperMesh添加预压力单元)
- DNS 学习笔记之三- 详解DNS的资源记录
- 帕金森病的功能性脑连接障碍:一项5年的纵向研究
- ffmpeg去除水印
- 你相信进化吗?探索通用人工智能的重要途径 | 算法观点
- ActiveX控件的MFC实现(VS2017,OpenGL)
- 我也是从寒门走出来的,程序员这个职业是我最好的选择!
- 【有利可图网】PS教程:用PS合成立体特效的穿插照片效果
热门文章
- Java中的状态设计模式
- weblogic中数据源_如何在WebLogic Server中创建MySQL数据源
- 跟踪反应流–将Spring Cloud Sleuth与Boot 2结合使用
- lambda表达式方法泛型_模板方法模式–使用Lambda表达式,默认方法
- 将Java应用程序作为Windows服务安装
- 编写下载服务器。 第二部分:标头:Last-Modified,ETag和If-None-Match
- 如何使用Spring Security和Basic身份验证保护Jersey REST服务
- JavaFX技巧10:自定义复合控件
- 优化您的ApplicationContext
- Java方法中的参数太多,第4部分:重载