📄 gmguiiir2.asv
字号:
function varargout = GMGUIIIR2(varargin)
% GMGUIIIR2 M-file for GMGUIIIR2.fig
% GMGUIIIR2, by itself, creates a new GMGUIIIR2 or raises the existing
% singleton*.
%
% H = GMGUIIIR2 returns the handle to a new GMGUIIIR2 or the handle to
% the existing singleton*.
%
% GMGUIIIR2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GMGUIIIR2.M with the given input arguments.
%
% GMGUIIIR2('Property','Value',...) creates a new GMGUIIIR2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GMGUIIIR2_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GMGUIIIR2_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 GMGUIIIR2
% Last Modified by GUIDE v2.5 13-Jan-2008 21:52:41
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GMGUIIIR2_OpeningFcn, ...
'gui_OutputFcn', @GMGUIIIR2_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 GMGUIIIR2 is made visible.
function GMGUIIIR2_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 GMGUIIIR2 (see VARARGIN)
% Choose default command line output for GMGUIIIR2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GMGUIIIR2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GMGUIIIR2_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;
wp=0.4*pi;
ws=0.6*pi;
ap=0.5;
as=50;
TT=2;
Wp=2/TT*tan(wp/2);
Ws=2/TT*tan(ws/2);
T=Ws/Wp;
K=sqrt((10^(ap/10)-1)/(10^(as/10)-1));
N=ceil(-log10(K)/log10(T));
% N=11;
Wc=min([Wp*(10^(ap/10)-1)^(-1/(2*N)),Ws*(10^(as/10)-1)^(-1/(2*N))]);
k2=1;
for i=1:N
s(i)=Wc*exp(j*pi*(1/2+(2*(i-1)+1)/(2*N)));
p2(i)=(1-s(i))/(1+s(i));
k2=-k2/(1+s(i));
end
z2=conj(repmat(-1,1,N))',k2=k2*Wc^N;
z1=[],p1=s,k1=Wc^N;% 零点、极点、增益
[b,a]=zp2tf(z1,p1,k1);
[f,g]=zp2tf(z2,p2,k2);
f=fliplr(f);
g=fliplr(g);
g0=[g,0];
[H2,w]=freqz(f,g,101);
[r,p,h]=residue(b,a);
[rr,pp,hh]=residue(f,g0);
t=0:0.1:100;
h1=zeros(1,length(t));
for i=1:N
h1=h1+r(i)*exp(p(i)*t);
end
n=0:50;
h2=zeros(1,length(n));
for i=1:N+1
for n=0:50
h2(n+1)=h2(n+1)+rr(i)*pp(i)^n;
end
end
axes(handles.axes1),plot(w/pi,20*log10(abs(H2)));
set(handles.axes1,'Xtick',[0 0.4 0.6 1],'Ytick',[-50 -0.5]);
axis([0 1 -60 0]);
title('幅频衰减特性');
xlabel('频率(ω/π)');
ylabel('衰减(dB)');
grid;
axes(handles.axes2),plot(t,h1,'m');
axis([0 100 -0.3 0.4]);
title('脉冲响应特性');
xlabel('t(s) n');
ylabel('ha(t) h(n)');
hold on;
axes(handles.axes2),stem(2*(0:50),h2,'.');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -