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

📄 ode2ss.m

📁 很多matlab的源代码
💻 M
字号:
function [a,b,c,d]=ode2ss(bi,ai,ty)
% ODE2SS Generates state model in phase variable form.
%
%	[A,B,C,D] = ODE2SS(a,b,ty) State model in PHASE VARIABLE form 
%	If ty = 's', a and b are coefficients of the DIFFERENTIAL equation 
%  	[Dn+a1Dn-1 + ... aN]y=[Dm+a1Dm-1 + ... bM]x 
%	If ty = 'z', a and b are coefficients of the DIFFERENCE equation
%       y[n]+a1y[n-1]+... = b0x[n]+b1x[n-1]+...
%
%        [A,B,C,D] = ODE2SS(NUM,DEN,ty) does the same from transfer function
%        H = NUM/DEN.
%
%	 DEFAULT: ty = 's'
%
%        ODE2SS (with no inout arguments) invokes the following example:
%        % Convert [s*s+4s+3]y =[2s+5]x to state equations
%        >>[aa,bb,cc,dd] = ode2ss([2 5],[1 4 3])

% Version 1.0
%Ashok Ambardar, EE Dept. MTU, Houghton MI.49931, USA
%e-mail: akambard@mtu.edu
%Copyright (c) 1993

if nargin==0,help ode2ss,disp('Strike a key to see results of the example')
pause,[aa,bb,cc,dd]=ode2ss([2 5],[1 4 3]),return,end

if nargin<3,ty='s';end
n=length(ai)-1;k=length(bi)-1;p=n-k;
if ty=='s',bi=[zeros(1,p) bi];else,bi=[bi zeros(1,p)];end
bi=bi/ai(1);ai=ai/ai(1);
if k>n,error('input order must be < output order'),return,end
d=0;
if bi(1)~=0;d=bi(1);bi=bi-bi(1)*ai;end,
bi(1)=[];
a=[zeros(n-1,1) eye(n-1)];a=[a;-ai(n+1:-1:2)];
b=[zeros(n-1,1);1];
c=bi(n:-1:1);

⌨️ 快捷键说明

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