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

📄 pf2tf.m

📁 很多matlab的源代码
💻 M
字号:
function [nn,dd] = pf2tf(u,v,k,tol)
% PF2TF Conversion of partial fractions to a transfer function.
%
%	[N,D] = PF2TF(R,P,K,TOL) Converts PF expansion to transfer function 
%	R, P, and K are provided by the PF expansion routine TF2PF
%       OR R, P are the residues and poles and
%	K are direct terms in the order [...x^2 x^1 x^0]. (DEFAULT: k=[])
%	TOL = tolerence for repeated roots [Default: TOL = 0.002].
%	N, D are the numerator and denominator of the transfer function
%
%       WARNING: PF2TF can be unstable especially for repeated poles.
%
%       PF2TF (with no input arguments) invokes the following example:
%
%       % Find the PF expansion of H(s)=[2*s*s+3s+4]/[s*s+4s+3]
%         >>[res,pol,cons] = tf2pf([2 3 4],[1 4 3])
%       % Then reassemble the results in TF form
%         >>[nx,dx]=pf2tf(res,pol,cons)
%
% Modified version of RESIDUE to accomodate user supplied tolerence
% Modified by A.Ambardar. 6-22-1991. With permission from The Mathworks, Inc.


% 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 pf2tf,disp('Strike a key to see results of the example')
pause,[res,pol,cons]=tf2pf([2 3 4],[1 4 3]),disp('Strike a key to continue'),
pause,[nx,dx]=pf2tf(res,pol,cons),return,end

if nargin<4,tol=0.002;end,
if nargin<3,k=[];end
[p,i]=sort(-abs(v));p=v(i);r=u(i);
n=length(p);q=[p(:).';ones(1,n)];
for j=2:n,if abs(p(j)-p(j-1))<tol,q(2,j)=q(2,j-1)+1;end,end
v=poly(p);u=zeros(1,n);
for indx=1:n
ptemp=q(1,:);i=indx;
for j=1:q(2,indx),ptemp(i)=[];i=i-1;end 
temp=poly(ptemp);temp=[zeros(1,n-length(temp)) temp];
u=u+(r(indx).*temp);
end
if ~isempty(k),if any(k ~= 0)
u=[zeros(1,length(k)) u];k=k(:).';temp=conv(k,v);u=u+temp;
end,end
nn=real(u);dd=real(v);nn=nn.*(abs(nn)>100*eps);dd=dd.*(abs(dd)>100*eps);
ln=length(nn);ld=length(dd);ze=abs(ln-ld);
if ln<ld,nn=[zeros(1,ze) nn];end,
if ld<ln,dd=[zeros(1,ze) dd];end

⌨️ 快捷键说明

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