zongy_comparison.m
来自「在MATLAB平台中设计一有限冲击响应滤波器」· M 代码 · 共 98 行
M
98 行
function varargout = zongy_comparison(varargin)
% ZONGY_COMPARISON M-file for zongy_comparison.fig
% ZONGY_COMPARISON, by itself, creates a new ZONGY_COMPARISON or raises the existing
% singleton*.
%
% H = ZONGY_COMPARISON returns the handle to a new ZONGY_COMPARISON or the handle to
% the existing singleton*.
%
% ZONGY_COMPARISON('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ZONGY_COMPARISON.M with the given input arguments.
%
% ZONGY_COMPARISON('Property','Value',...) creates a new ZONGY_COMPARISON or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before zongy_comparison_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to zongy_comparison_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_comparison
% Last Modified by GUIDE v2.5 11-Sep-2007 11:18:45
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @zongy_comparison_OpeningFcn, ...
'gui_OutputFcn', @zongy_comparison_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_comparison is made visible.
function zongy_comparison_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_comparison (see VARARGIN)
% Choose default command line output for zongy_comparison
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes zongy_comparison wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = zongy_comparison_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); wind2=boxcar(N); %使用哈明窗、矩形窗
b1=fir1(N-1,[w1/pi,w2/pi],wind1);
b2=fir1(N-1,[w1/pi,w2/pi],wind2);%使用标准频率的加窗设计函数fir1n=-200:200;
t=n/fs;
x=s+i; %叠加之后的混合信号
sf1=filter(b1,1,x); sf2=filter(b2,1,x); %利用滤波函数对混合信号进行滤波
i1=filter(b1,1,i);i2=filter(b2,1,i); %利用滤波函数对噪声信号进行滤波
axes(handles.axes1);plot(t,sf1);axis([0,8,-10,10]);ylabel('哈明窗');title('滤波信号');grid;
axes(handles.axes2);plot(t,sf2);axis([0,8,-10,10]);ylabel('矩形窗');xlabel('单位(ms)');grid;
axes(handles.axes3);plot(t,i1);axis([0,8,-2,2]);ylabel('哈明窗');title('滤波后的噪声部分');grid;
axes(handles.axes4);plot(t,i2);axis([0,8,-2,2]);ylabel('矩形窗');xlabel('单位(ms)');grid;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?