clc;
clear;
%x=wavread('01.wav'); %读取语音文件
x=wavread('a.wav');
N=200; %设定帧长
M=80; %设定个帧交叠部分的长度
xn=enframe(x,N,M); %按照指定的要求分帧
%size(xn)
s=xn(:,70); %取分帧后的某一帧进行分析
n=length(s);
p=18;
num=512; %设定频谱的点数
a=lpc_coefficients(s,p); %按所要求阶数求线性预测系数
a2 =lpc(s,p); %利用信号处理工具箱中的函数lpc求预测系数
cm=cepstrum(s); %求语音信号的倒谱
h_c=lpc_cepstrum(s,p); %求lpc倒谱,即声道冲激响应h(n)的倒谱
Hw=lpc_spectrum(s,p,num); %求lpc的谱估计,num为频谱的点数
[P_w,Q_w,H]=lsp(s,p,num); %求语音信号的线谱对参数
colordef black; %设置背景颜色为黑色
choice=4;
if choice==1
clf; %清除当前的图形窗口
subplot(2,1,1);
plot(a);
title('我程序求得的预测系数');
subplot(2,1,2);
plot(-a2(2:p+1),'y')
title('Matlab函数求得的预测系数');
elseif choice==2
clf; %清除当前的图形窗口
subplot(2,1,1);
plot(cm(2:n),'y');
title('语音信号的倒谱');
subplot(2,1,2);
plot(h_c,'y');
title('lpc倒谱');
elseif choice==3
clf; %清除当前的图形窗口
subplot(2,1,1);
Sw=abs(fft(s,num)); %语音信号的短时谱
axis([0 256 0 1]);
hold on;
plot(Sw/max(Sw),'y');
title('语音信号的短时谱');
subplot(2,1,2);
axis([0 256 0 1]);
hold on
plot(Hw/max(Hw),'y');
title('lpc谱估计');
else
clf; %清除当前的图形窗口
subplot(3,1,1);
stem(Q_w,zeros(p/2,1),'r','fill');
hold on;
stem(P_w,zeros(p/2,1),'y','fill');
title('线谱对系数');
hold off;
subplot(3,1,2);
axis([0 256 0 1]);
hold on
plot(abs(Hw)/max(abs(Hw)),'y');
title('lpc谱估计');
subplot(3,1,3);
axis([0 256 0 1]);
hold on
plot(H/max(H),'y');
title('由线谱对求得的谱估计');
end
MatLab时域分析与频域分析的程序
4星 · 超过85%的资源 需积分: 49 36 浏览量
2010-10-12
19:58:46
上传
评论 24
收藏 6KB RAR 举报
dimplelady
- 粉丝: 2
- 资源: 9
最新资源
- C语言基础-C语言编程基础之Leetcode编程题解之第39题组合总和.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第38题外观数列.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第37题解数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第36题有效的数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第35题搜索插入位置.zip
- index.wxml
- C语言基础-C语言编程基础之Leetcode编程题解之第33题搜索旋转排序数组.zip
- 基于Python实现的手写数字识别系统源码.zip
- 从网页提取禁止转载的文字
- C语言基础-C语言编程基础之Leetcode编程题解之第32题最长有效括号.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
- 6
前往页