transfr.m
来自「线性时变系统控制器设计的工具包」· M 代码 · 共 130 行
M
130 行
% function [a,b1,b2,c1,c2,d11,d12,d21,d22,r12inv,r21inv,q12,q21,fail] = ...% transfr(sys,nmeas,nctrl,nsf)%% This program is designed to scale the d12 and d21 matrices to satisfy the % standard formulas and check the rank conditions.%% MODIFICATION (Sep 4, 1996): it now works with the output-and-partial-state% feedback problem, i.e., the last nsf outputs can be y2 = [0 Ci] x% (where Ci is square and invertible), i.e. exact state measurements. % These are extracted, the rest of the plant is transformed as in the % regular output feedback problem, and then the extra outputs are put back % (after transforming y2 to Ci\y2). function [a,b1,b2,c1,c2,d11,d12,d21,d22,r12inv,r21inv,q12,q21,fail] = ... transfr(sys,nmeas,nctrl,nsf) [systype,no,ni,nx] = minfo(sys); if ~exist('nsf') nsf = 0; end nx1 = nx - nsf; ny1 = nmeas - nsf; nd = ni-nctrl; nu = nctrl; ne = no-nmeas; ny = nmeas; [a,b,c,d] = unpck(sys); b1 = b(:,1:nd); b2 = b(:,nd+1:ni); c1 = c(1:ne,:); c2 = c(ne+1:no,:); d11 = d(1:ne,1:nd); d12 = d(1:ne,nd+1:ni); d21 = d(ne+1:no,1:nd); d22 = d(ne+1:no,nd+1:ni); fail = 0;%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Check the last nsf measurements for the structure y2 = [0 Ci] x% where Ci is square and invertible. if any(any([c2(ny1+1:nmeas,1:nx1) d21(ny1+1:nmeas,:)])) disp(' THE LAST OUTPUTS ARE NOT STATE MEASUREMENTS') fail = 1; return; end c22 = c2(ny1+1:nmeas,nx1+1:nx); if abs(det(c22)) < eps disp(' THE EXACT PARTIAL-STATE MEASUREMENT GAIN IS SINGULAR') fail = 1; return; end c2 = c2(1:ny1,:); d21 = d21(1:ny1,:);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Determine if |A-jwI B2 | has full column rank at w = 0.% | C1 D12|% ctmp = [a b2;c1 d12]; [nr,nc] = size(ctmp); crk = rank(ctmp,eps); if (crk ~= nc) disp(' [A B2;C1 D12] DOES NOT HAVE FULL COLUMN RANK AT W = 0 ') fail = 1; return; end%% Determine if |A-jwI B1 | has full row rank at w = 0.% | C2 D21|% rtmp = [a b1;c2 d21]; [nr,nc] = size(rtmp); rrk = rank(rtmp,eps); if (rrk ~= nr) disp(' [A B1;C2 D21] DOES NOT HAVE FULL ROW RANK AT W = 0 ') fail = 1; return; end%% Determine if D12 has full row rank and scale D12 to Q12*D12*R12INV = |0|.% |I|% [q12,r12] = qr(d12); rrk = rank(r12,eps); if (rrk ~= nctrl) disp(' D12 DOES NOT HAVE FULL ROW RANK') fail = 1; return; end q12 = [q12(:,(nu+1):ne),q12(:,1:nu)]'; r12inv = inv(r12(1:nu,:));%% Determine if D21 has full column rank and scale D21 to R21INV'*D21*Q21 = [0 I].% [q21,r21] = qr(d21'); crk = rank(r21,eps); if (crk ~= ny1) disp(' D21 HAS INSUFFICIENT COLUMN RANK') fail = 1; return; end if isempty(d21) q21 = eye(nd); else q21 = [q21(:,(ny1+1):nd),q21(:,1:ny1)]; end r21inv = inv(r21(1:ny1,:)); c1 = q12*c1; c2 = r21inv'*c2;% cc = [c1;c2]; b1 = b1*q21; b2 = b2*r12inv;% bb = [b1,b2]; d11 = q12*d11*q21; d12 = [zeros(ne-nctrl,nctrl);eye(nctrl)]; d21 = [zeros(ny1,nd-ny1) eye(ny1)]; d22 = d22;% dd = [d11 d12;d21 d22];% sys = pck(aa,bb,cc,dd);%%%% New versions for partial-state measurements:c2 = [c2; zeros(nsf,nx1) eye(nsf)];d21 = [d21; zeros(nsf,nd)];r21inv = daug(r21inv,inv(c22));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?