📄 zongy_hamming.m
字号:
function varargout = zongy_hamming(varargin)
% ZONGY_HAMMING M-file for zongy_hamming.fig
% ZONGY_HAMMING, by itself, creates a new ZONGY_HAMMING or raises the existing
% singleton*.
%
% H = ZONGY_HAMMING returns the handle to a new ZONGY_HAMMING or the handle to
% the existing singleton*.
%
% ZONGY_HAMMING('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ZONGY_HAMMING.M with the given input arguments.
%
% ZONGY_HAMMING('Property','Value',...) creates a new ZONGY_HAMMING or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before zongy_hamming_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to zongy_hamming_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
% Edit the above text to modify the response to help zongy_hamming
% Last Modified by GUIDE v2.5 11-Sep-2007 10:18:14
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @zongy_hamming_OpeningFcn, ...
'gui_OutputFcn', @zongy_hamming_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 zongy_hamming is made visible.
function zongy_hamming_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 zongy_hamming (see VARARGIN)
% Choose default command line output for zongy_hamming
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes zongy_hamming wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = zongy_hamming_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 pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)load Data_7 s i;
fp1=3;fp2=6;fs=20;
N=35; %滤波器的阶数
w1=2*pi*fp1/fs;w2=2*pi*fp2/fs;%将模拟滤波器的指标转换为数字滤波器的指标
wind1=hamming(N); %使用哈明窗
b1=fir1(N-1,[w1/pi,w2/pi],wind1);%使用标准频率的加窗设计函数fir1
[h1,f1]=freqz(b1,1,512,fs); %在0到fs/2频率范围内选取512个频率点(记录在f中),计算相应的频率响应
axes(handles.axes6);plot(f1,20*log10(abs(h1)));
%xlabel('频率(KHz)');
ylabel('滤波器的幅频响应曲线');grid;
axes(handles.axes7);plot(f1,unwrap(angle(h1)));
xlabel('频率(KHz)');ylabel('滤波器的相频响应曲线');grid;
[gd1 f11]=grpdelay(b1,1,512,20);
tt1=3.4;nn1=tt1*f1;
axes(handles.axes8);plot(nn1,gd1);grid;
xlabel('Samples(n)');ylabel('滤波器的群延迟');
n=-200:200;
t=n/fs;
x=s+i; %叠加之后的混合信号
sf1=filter(b1,1,x); %利用滤波函数对混合信号进行滤波
i1=filter(b1,1,i); %利用滤波函数对噪声信号进行滤波
axes(handles.axes1);plot(t,s);axis([0,8,-10,10]);ylabel('原始信号');grid;
axes(handles.axes2);plot(t,i);axis([0,8,-10,10]);ylabel('噪声信号');grid;
axes(handles.axes3);;plot(t,x);axis([0,8,-10,10]);ylabel('混合信号');grid;
axes(handles.axes4);plot(t,sf1);axis([0,8,-10,10]);ylabel('滤波信号');grid;
axes(handles.axes5);plot(t,i1);axis([0,8,-10,10]);ylabel('滤波后的噪声部分');xlabel('单位(ms)');grid;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -