📄 z2smap.m
字号:
function [nn,dd] = z2smap(n,d,fs,ty,fm)
% Z2SMAP Convert H(z) to H(s) using various z2s mappings.
%
% [Ns,Ds] = Z2SMAP(Nz,Dz,SF,TY,FM) converts H(z) to H(s)
% Nz, Dz are mum and den of H(z) in descending powers of z.
% SF = sampling frequency in HERTZ,
% TY = z2s mapping method and can be one of the following:
% 'back', 'forw', 'rect' : backward/forward/difference/rectangular rule
% 'tust' or 'trap' or 'bilin': Bilinear (Tustin or Trapezoidal) rule
% 'pade' : Pade approximation to delay of order FM
%
% IF TY = 'pade', FM = approximation order (1 to 4) [default: FM = 1]
% If TY = 'trap', FM = [FA FD] = analog & digital match frequency (HERTZ)
%
% Ns, Ds return the num and den of H(s)
%
% Z2SMAP (with no input arguments) invokes the following example:
%
% % Convert H(z)=z/(z-0.5) to H(s) using the bilinear transformation
% % and a sampling frequency of 10Hz
% >>[nt,dt] = z2smap([1 0],[1 -.5],10,'trap')
% ADSP Toolbox: Version 2.0
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998
if nargin==0,help z2smap,disp('Strike a key to see results of the example')
pause,[nt,dt]=z2smap([1 0],[1 -.5],10,'trap'),return,end
if nargin<4,ty='trap';end,
ty=ty(1:4);
if nargin<3,fs=1;end
t0=1/fs;
if (ty=='back'| ty=='rect'),
na=[0 -fs];da=[1 -fs];
elseif ty=='forw',
na=[1 fs];da=fs; %forward(1)
elseif (ty=='trap'|ty=='tust'|ty=='bili')
c=2*fs;
if nargin==5,fa=fm(1);
if length(fm)>1,fd=fm(2);else,fd=fa;end
if 2*fd>=fs,error('Digital Match freq. exceeds 0.5*fsamp'),return,end
c=2*pi*fa/tan(pi*fd/fs);
end,
na=[-1 -c];da=[1 -c]; %Trap
elseif ty=='pade'
if nargin<5,fm=1;end,
da1=[-t0/2 1];t2=t0*t0;t3=t2*t0;t4=t3*t0;
if fm==1,da=da1;
elseif fm==2,da=[t2/12 da1];
elseif fm==3,da=[-t3/120 t2/10 da1];
elseif fm==4,da=[t4/1680 -t3/84 3*t2/28 da1];
else,error('Use only orders 1 thru 4'),return,end
na=abs(da);
else,error('Unknown mapping type'),return,end
[nn,dd]=polymap(n,d,na,da);
if dd(1)<0,dd=-dd;nn=-nn;end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -