function varargout = untitled2(varargin)
% UNTITLED2 M-file for untitled2.fig
% UNTITLED2, by itself, creates a new UNTITLED2 or raises the existing
% singleton*.
%
% H = UNTITLED2 returns the handle to a new UNTITLED2 or the handle to
% the existing singleton*.
%
% UNTITLED2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED2.M with the given input arguments.
%
% UNTITLED2('Property','Value',...) creates a new UNTITLED2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled2_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled2_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help untitled2
% Last Modified by GUIDE v2.5 16-Dec-2011 18:46:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled2_OpeningFcn, ...
'gui_OutputFcn', @untitled2_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled2 is made visible.
function untitled2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled2 (see VARARGIN)
% Choose default command line output for untitled2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled2_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in getfile.
function getfile_Callback(hObject, eventdata, handles)
% hObject handle to getfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global player;
[fname,pn,fi]=uigetfile('*.wav');
global Fname;
Fname=fname;
% --- Executes on button press in Play.
function Play_Callback(hObject, eventdata, handles)
% hObject handle to Play (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global Fname;
global sig;
global player;
global fs;
[y,fs,nbits]=wavread(Fname);
sig=y;
voice=get(handles.Vol,'Value')+2; %handles.变量名
spead=get(handles.Speed,'Value')+0.5;
player=audioplayer(y*voice,fs*spead);
play(player);
pause(3);
% --- Executes on button press in Stop.
function Stop_Callback(hObject, eventdata, handles)
% hObject handle to Stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global player;
pause(player);
% --- Executes on button press in Resume.
function Resume_Callback(hObject, eventdata, handles)
% hObject handle to Resume (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global player;
resume(player);
% --- Executes on button press in Time.
function Time_Callback(hObject, eventdata, handles)
% hObject handle to Time (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sig;
figure(1);plot(sig);title('时域波形');
% --- Executes on button press in Frequency.
function Frequency_Callback(hObject, eventdata, handles)
% hObject handle to Frequency (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sig;
Y=fft(sig);
mag=abs(Y);
phase=angle(Y);
phase=phase*180/pi;
figure(1);
subplot(3,1,1),plot(Y);
title('频谱响应');
subplot(3,1,2),plot(mag);
title('幅频响应');
subplot(3,1,3),plot(phase);
title('相频响应');
% --- Executes on button press in Highpass.
function Highpass_Callback(hObject, eventdata, handles)
% hObject handle to Highpass (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fs;
global sig;
x=sig;
sound(x,fs);
figure(1);subplot(4,1,1);plot(x);title('滤波前的信号时域波形');
Y=fft(x,fs);
subplot(4,1,2);
plot(abs(Y(1:length(Y)/2)));
title('滤波前信号的频谱');
prompt={'阻带截止频率','通带截止频率'};
name='选择参数';
numlines=1;
defAns={'550','650'}
answer=inputdlg(prompt,name,1,defAns);
ws=str2num(answer{1});
wp=str2num(answer{2});
wzp=2*pi*wp/fs;wzs=2*pi*ws/fs;
Bt=wzp-wzs;
N1=ceil(8*pi/Bt);
wc=wzs+Bt/2;
hn=fir1(N1,wc,'high');%注意格式。没有hanning(N+1) ?缺省则默认为哈明窗.
wf=0:pi/511:pi;
HK=freqz(hn,wf);
wHz=wf*511/(2*pi); % 转化为Hz
subplot(4,1,3);
plot(20*log10(abs(HK)));%绘制损耗曲线
%plot(wHz,20*log10(abs(HK)));
xlabel('频率(Hz)');ylabel('幅度');
z=fftfilt(hn,x);% 进行滤波
Y1=fft(z,fs);
subplot(4,1,4);
plot(abs(Y1(1:length(Y)/2)));
title('滤波后信号的频谱');
pause(1);
sound(z,fs);
% --- Executes on button press in Lowpass.
function Lowpass_Callback(hObject, eventdata, handles)
% hObject handle to Lowpass (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fs;
global sig;
x=sig;
sound(x,fs);
figure(1);subplot(4,1,1);plot(x);title('滤波前的信号时域波形');
Y=fft(x,fs);
subplot(4,1,2);
plot(abs(Y(1:length(Y)/2)));
title('滤波前信号的频谱');
prompt={'阻带截止频率','通带截止频率'};
name='选择参数';
numlines=1;
defAns={'650','500'}
answer=inputdlg(prompt,name,1,defAns);
ws=str2num(answer{1});
wp=str2num(answer{2});
wzp=2*pi*wp/fs;wzs=2*pi*ws/fs;
Bt=wzs-wzp;
N1=ceil(8*pi/Bt);
wc=wzp+Bt/2;
hn=fir1(N1-1,wc,hanning(N1));
wf=0:pi/511:pi;
HK=freqz(hn,wf);
wHz=wf*511/(2*pi); % 转化为Hz
subplot(4,1,3);
plot(20*log10(abs(HK)));%绘制损耗曲线
%plot(wHz,20*log10(abs(HK)));
xlabel('频率(Hz)');ylabel('幅度');
z=fftfilt(hn,x);% 进行滤波
Y1=fft(z,fs);
subplot(4,1,4);
plot(abs(Y1(1:length(Y)/2)));
title('滤波后信号的频谱');
pause(1);
sound(z,fs);
% --- Executes on button press in Bandpass.
function Bandpass_Callback(hObject, eventdata, handles)
% hObject handle to Bandpass (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fs;
global sig;
x=sig;
sound(x,fs);
figure(1);subplot(4,1,1);plot(x);title('滤波前的信号时域波形')
nickifyoung
- 粉丝: 0
- 资源: 1
最新资源
- IPMSM永磁电机弱磁控制 附有说明文档 公式法MTPA 采用电压反馈弱磁 波形很好 跟踪很稳 包含仿真文件和两个详细说明文档 简单易懂
- MySQL学生成绩管理系统
- 面向目标探测与跟踪的相控阵雷达波束调度策略研究 开题报告答辩.pptx
- 考虑风光火储和电动汽车的微电网经济调度 软件:Matlab+cplex工具箱 介绍:在Matlab 平台上以一个包含风、光、柴油发电机、上级电网、储能以及电动汽车的小型微电网系统为例进行仿真 目标包
- springboot校园在线拍卖系统
- 广东墨睿科技有限公司创投信息
- STM32L0xx官方开发包
- 故障诊断分类 matlab代码 轴承内圈、外圈、滚动体故障分类 (1)故障样本的时域、频域、时频域、熵等特征提取; (2)BP网络或者SVM模型训练与测试 (3)输出测试样本分类准确率 成套代码,注释
- 冲床送料机程序 中达优控一体机编写 此程序已经实际设备上批量应用,程序成熟可靠,借鉴价值高,程序有注释
- tensorflow用户实验报告
- 杭州华卓信息科技有限公司创投信息
- 含电池储能+pid控制器的两区域互联网电网调频仿真
- 毕业设计B058-基于Java的卓越导师双选系统的设计与实现
- 杭州孝道科技有限公司创投信息
- 儿童节烟花代码2python实现
- 大厂成熟FOC直流电机控制方案,此方案可用于电动自行车,滑板车等电机驱动 单片机基于Stm031或相应兆易GD32等单片机 转把,高中低三速 刹车功能 助力功能 电子刹车功能 欠压检测 巡航
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈