⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmguifir.m

📁 数字信号处理:1.卷积 2.抽样 3.滤波器
💻 M
字号:
function varargout = GMGUIFIR(varargin)
% GMGUIFIR M-file for GMGUIFIR.fig
%      GMGUIFIR, by itself, creates a new GMGUIFIR or raises the existing
%      singleton*.
%
%      H = GMGUIFIR returns the handle to a new GMGUIFIR or the handle to
%      the existing singleton*.
%
%      GMGUIFIR('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GMGUIFIR.M with the given input arguments.
%
%      GMGUIFIR('Property','Value',...) creates a new GMGUIFIR or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GMGUIFIR_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GMGUIFIR_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 GMGUIFIR

% Last Modified by GUIDE v2.5 17-Jan-2008 14:24:42
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GMGUIFIR_OpeningFcn, ...
                   'gui_OutputFcn',  @GMGUIFIR_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 GMGUIFIR is made visible.
function GMGUIFIR_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 GMGUIFIR (see VARARGIN)

% Choose default command line output for GMGUIFIR
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GMGUIFIR wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = GMGUIFIR_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)clear i;
ws1=0.25*pi;
wl=0.35*pi;
wu=0.65*pi;
ws2=0.75*pi;
d1=0.05;
d2=0.01;
ap=-20*log10((1-d1)/(1+d1));
as=-20*log10(d2/(1+d1));
dw=min([ws2-wu,wl-ws1]);
N=ceil((as-7.95)/(14.36*dw/(2*pi))+1)+1;
N=N+1;
% N=49
a=(N-1)/2;
n=0:N-1;
wc1=(ws1+wl)/2;
wc2=(ws2+wu)/2;
hd=sin(wc2*(n-a+eps))./(pi*(n-a+eps))-sin(wc1*(n-a+eps))./(pi*(n-a+eps));% 理想带通
A=3.7;
B=A*sqrt(1-(2*n/(N-1)-1).^2);
IoA=1;
IoB=ones(1,N);
for k=1:25
    IoA=IoA+(1/prod(1:k)*(A/2)^k)^2;
    for i=1:N
        IoB(i)=IoB(i)+(1/prod(1:k)*(B(i)/2)^k)^2;
    end
end
wn=IoB/IoA;
h=hd.*wn;
w=linspace(0,pi,2048);
H=fft(h,2048);
axes(handles.axes1),stem(n,hd,'.');
title('理想脉冲响应:带通');
xlabel('n');
ylabel('h_d(n)');
axes(handles.axes2),stem(n,wn,'.');
title('凯塞窗');
xlabel('n');
ylabel('w_k_a_i_s_e_r(n)');
axes(handles.axes3),stem(n,h,'.');
title('实际脉冲响应:带通');
xlabel('n');
ylabel('h(n)');
axes(handles.axes4),plot(2*w/pi,20*log10(abs(H)));
set(handles.axes4,'Xtick',[0 0.25 0.35 0.65 0.75 1],'Ytick',[-40.424 -0.869]);
axis([0 1 -70 0]);
title('幅频衰减特性     衰减(dB)');
xlabel('频率(π)');
grid;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -