This commit is contained in:
2023-11-14 17:10:27 +08:00
commit d5a822831c
423 changed files with 5909 additions and 0 deletions

16
FOTF Toolbox/@foss/bode.m Normal file
View File

@ -0,0 +1,16 @@
function H=bode(G,varargin)
% bode - draw Bode diagram for an FOSS object
%
% bode(G,w)
% H=bode(G,w)
%
% G - the FOSS object
% w - the frequency vector
% H - the frequency response data in FRD format
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
if nargout==0, bode(fotf(G),varargin{:});
else, H=bode(fotf(G),varargin{:}); end
end

View File

@ -0,0 +1,21 @@
function G1=coss_aug(G,k)
% coss_aug - state augmentation of an FOSS object
%
% G1=coss_aug(G,k)
%
% G - the FOSS object
% k - integer so that original n states can be augmented into n*k states
% G1 - the augmented FOSS model
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
if G.alpha==0 || k==1, G1=G;
else, alpha=G.alpha/k; G=fotf(G); [n,m]=size(G);
for i=1:n, for j=1:m, g=G(i,j);
a=g.den.a; na=g.den.na; b=g.num.a; nb=g.num.na;
ii=1:k:k*length(a); a1(ii)=a;
ii=1:k:k*length(b); b1(ii)=b; G2(i,j)=tf(b1,a1);
end, end
G1=foss(ss(G2)); G1.alpha=alpha;
end, end

13
FOTF Toolbox/@foss/ctrb.m Normal file
View File

@ -0,0 +1,13 @@
function Tc=ctrb(G)
% ctrb - create a controllability test matrix for an FOSS
%
% Tc=ctrb(G)
%
% G - the FOSS object
% Tc - the controllability test matrix
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
Tc=ctrb(G.a,G.b);
end

14
FOTF Toolbox/@foss/disp.m Normal file
View File

@ -0,0 +1,14 @@
function disp(G)
% display - display an FOSS. This function will be called automatically
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
disp('E*(d^alpha*X)(t)=A*X(t)+B*U(t-T)'), T=G.ioDelay;
disp('Y(t)=C*X(t)+D*U(t-T)'); ss(G.a,G.b,G.c,G.d)
if ~isempty(G.E), disp('Descriptor matrix'), E=G.E, end
if sum(T(:)), disp(['Time Delay is = ' mat2str(T)]); end
disp(['alpha = ',num2str(G.alpha)]);
if ~isempty(G.x0), x0=G.x0;
disp(['Initil state vector x0 = [' num2str(x0(:).'),']'])
end, end

13
FOTF Toolbox/@foss/eig.m Normal file
View File

@ -0,0 +1,13 @@
function p=eig(G)
% eig - finding all the pseudo poles of an FOSS object
%
% p=eig(G)
%
% G - the FOSS object
% p - all the pseudo-poles of G
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
p=eig(G.a)
end

13
FOTF Toolbox/@foss/eq.m Normal file
View File

@ -0,0 +1,13 @@
function key=eq(G1,G2)
% eq - test whether two FOSS objects are equal or not
%
% key=G1==G2
%
% G1, G2 - the two FOSS objects
% key = 1 for equal, otherwise key = 0
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
key=fotf(G1)==fotf(G2);
end

View File

@ -0,0 +1,24 @@
function G=feedback(G1,G2)
% feedback - find the overall model of two FOSS objects in feedback connection
%
% G=feedback(G1,G2)
%
% G1, G2 - the FOSS objects in the forward and backward paths
% G - the overall model of the closed-loop system
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
G1=foss(G1); G2=foss(G2);
if length(G1.alpha)>1 || length(G2.alpha)>1, a=0.0001;
else, a=common_order(G1.alpha,G2.alpha); end
if a==0
G=foss([],[],[],G1.d*inv(eye(size(G1.d))+G2.d*G1.d),0);
elseif a<0.001
G1=fotf(G1); G2=fotf(G2); G=foss(feedback(G1,G2));
else
G1=coss_aug(G1,round(G1.alpha/a));
G2=coss_aug(G2,round(G2.alpha/a));
G=foss(feedback(ss_extract(G1),ss_extract(G2))); G.alpha=a;
end
end

25
FOTF Toolbox/@foss/foss.m Normal file
View File

@ -0,0 +1,25 @@
% foss - class constructor for an FOSS class
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
classdef foss
properties, a, b, c, d, alpha, ioDelay, E, x0, end
methods
function G=foss(a,b,c,d,alpha,L,E,x0)
if nargin<=7, x0=[]; end
if nargin<=6, E=[]; end, if nargin<=5, L=0; end
if nargin==1 && isa(a,'foss'), G=a;
elseif nargin==1 && isa(a,'fotf'), G=fotf2foss(a);
elseif nargin==1 && isa(a,'double'), G=foss([],[],[],a,0);
elseif (nargin==1||nargin==2) && (isa(a,'tf')||isa(a,'ss'))
alpha=1; if nargin==2, alpha=b; end
a=ss(a); L=a.ioDelay; [a,b,c,d,E]=dssdata(a);
G=foss(a,b,c,d,alpha,L,E);
elseif nargin>=5, msg=abcdchk(a,b,c,d);
if length(msg)>0, error(msg)
else, G.alpha=alpha; G.x0=x0;
G.a=a; G.b=b; G.c=c; G.d=d; G.E=E; G.ioDelay=L;
end
else, error('wrong input arguments'); end
end, end, end

View File

@ -0,0 +1,24 @@
function G1=foss2fotf(G)
% foss2fotf - convert an FOSS object to FOTF one
%
% G1=foss2fotf(G)
%
% G - an FOSS object
% G1 - an equivalent FOTF object
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
[n,m]=size(G); G1=fotf(zeros(n,m));
G0=ss_extract(G); G0=tf(G0); key=length(G.alpha)>1;
T=G.ioDelay; if isscalar(T), T=T*ones(n,m); end
if key~=0
n0=G.alpha; n1=n0(end:-1:1); n2=0;
for i=1:length(n1), n2(i+1)=n2(i)+n1(i); end
n2=n2(end:-1:1);
end
for i=1:n, for j=1:m, g=G0(i,j);
[num,den]=tfdata(g,'v');
if key==0, n2=((length(den)-1):-1:0)*G.alpha; end
h=fotf(den,n2,num,n2,T(i,j)); h=simplify(h); G1(i,j)=h;
end, end, end

View File

@ -0,0 +1,15 @@
function Y=impulse(G,varargin)
% impulse - impulse response evaluation of an FOSS object
%
% impulse(G,t)
%
% G - an FOSS object
% t - the time vector
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
if nargout==0, impulse(fotf(G),varargin{:});
else, Y=impulse(fotf(G),varargin{:});
end
end

12
FOTF Toolbox/@foss/inv.m Normal file
View File

@ -0,0 +1,12 @@
function G1=inv(G)
% inv - inverse of a multivariable FOSS system
%
% G1=inv(G)
%
% G, G1 - an FOSS object and its inverse system
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
H=inv(ss_extract(G)); G1=foss(H); G1.alpha=G.alpha;
end

View File

@ -0,0 +1,12 @@
function key=isfoss(G)
% isfoss - check whether input is an FOSS object
%
% key=isfoss(G)
%
% G - an FOSS object
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
key=strcmp(class(G),'foss');
end

View File

@ -0,0 +1,20 @@
function [K,alpha,apol]=isstable(G)
% isstable - check whether an FOSS object is stable or not
%
% [K,alpha,apol]=isstable(G)
%
% G - an FOSS object
% K- identifier to indicate the stability of G, returns 0, and 1
% alpha - the common order
% apol - all the pseudo poles of the system
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
p=eig(G); alpha=G.alpha;
plot(real(p),imag(p),'x',0,0,'o')
apol=min(abs(angle(p))); K=apol>alpha*pi/2;
xm=xlim; if alpha<1, xm(1)=0; else, xm(2)=0; end
a1=tan(alpha*pi/2)*xm; a2=tan(alpha*pi)*xm;
line(xm,a1), line(xm,-a1), line(xm,a2), line(xm,-a2)
end

15
FOTF Toolbox/@foss/lsim.m Normal file
View File

@ -0,0 +1,15 @@
function Y=lsim(G,varargin)
% lsim - simulation of an FOSS object driven by given inputs
%
% lsim(G,u,t)
%
% G - an FOSS object
% u, t- input samples and time vector
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
if nargout==0, lsim(fotf(G),varargin{:});
else, Y=lsim(fotf(G),varargin{:});
end
end

View File

@ -0,0 +1,14 @@
function [Gm,Pm,Wcg,Wcp]=margin(G)
% margin - gain and phase margins of an FOSS object
%
% [Gm,Pm,Wcg,Wcp]=margin(G)
%
% G - an FOSS object
% Gm, Wcg - gain margin in dBs and the corresponding frequency
% Pm, Wcp - phase margin in degrees and the crossover frequency
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
[Gm,Pm,Wcg,Wcp]=margin(fotf(G));
end

14
FOTF Toolbox/@foss/mfrd.m Normal file
View File

@ -0,0 +1,14 @@
function H=mfrd(G,varargin)
% mfrd - evaluation of frequency responses of an FOSS object
%
% H=mfrd(G,w)
%
% G - an FOSS object
% w - frequency vector
% H - frequency response of G in MFD format
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
H=mfrd(fotf(G),varargin{:});
end

View File

@ -0,0 +1,14 @@
function G=minreal(G1)
% minreal - minimum realisation of an FOSS object
%
% G=minreal(G1)
%
% G1 - an FOSS object
% G - minimum realisation of G1 as an FOSS object
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
alpha=G1.alpha; G2=ss_extract(G1); G2=minreal(G2);
G=foss(G2); G.alpha=alpha;
end

View File

@ -0,0 +1,10 @@
function G=minus(G1,G2)
% minus - minus operation of two FOSS objects
%
% G=G1-G2
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
G=G1+(-G2);
end

View File

@ -0,0 +1,20 @@
function G1=mpower(G,n)
% mpower - power of an FOSS object
%
% G1=G^n
%
% G - an FOSS object
% n - power. If G is s or constant, n can be any real number,
% If G is an FOSS, n should be integers
% G1 - returns G^n, and an FOSS object
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
if n==fix(n), [n1,m1]=size(G); if n<0, G=inv(G); end
if n1==m1
G1=foss(eye(n1)); for i=1:abs(n), G1=G1*G; end
else, error('matrix must be square'); end
else, error('mpower: power must be an integer.');
end
end

View File

@ -0,0 +1,22 @@
function G=mtimes(G1,G2)
% mpower - product of two FOSS objects, series connection
%
% G=G1*G2
%
% G1, G2 - FOSS objects
% G - returns the product of the two FOSS objects
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
G1=foss(G1); G2=foss(G2);
if length(G1.alpha)>1 || length(G2.alpha)>1, a=0.0001;
else, a=common_order(G1.alpha,G2.alpha); end
if a==0, G=foss([],[],[],G1.d*G2.d,0);
elseif a<0.001, G1=fotf(G1); G2=fotf(G2); G=foss(G1*G2);
else
G1=coss_aug(G1,round(G1.alpha/a));
G2=coss_aug(G2,round(G2.alpha/a));
G=foss(ss_extract(G1)*ss_extract(G2)); G.alpha=a;
end
end

View File

@ -0,0 +1,15 @@
function H=nichols(G,varargin)
% nichols - draw the Nichols chart of an FOSS object
%
% nichols(G,w)
%
% G - an FOSS object
% w - the frequency vector
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
if nargout==0, nichols(fotf(G),varargin{:});
else, H=nichols(fotf(G),varargin{:});
end
end

13
FOTF Toolbox/@foss/norm.m Normal file
View File

@ -0,0 +1,13 @@
function n=norm(G,varargin)
% norm -= norms of an FOSS object
%
% norm(G), norm(G,inf)
%
% G - an FOSS object
% The 2-norm and infinity-norm of G can be evaluated, respectively
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
n=norm(fotf(G),varargin{:});
end

View File

@ -0,0 +1,15 @@
function H=nyquist(G,varargin)
% nyquist - draw the Nyquist plot of an FOSS object
%
% nyquist(G,w)
%
% G - an FOSS object
% w - the frequency vector
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
if nargout==0, nyquist(fotf(G),varargin{:});
else, H=nyquist(fotf(G),varargin{:});
end
end

13
FOTF Toolbox/@foss/obsv.m Normal file
View File

@ -0,0 +1,13 @@
function To=obsv(G)
% obsv - create an observability test matrix for an FOSS
%
% To=obsv(G)
%
% G - the FOSS object
% To - the observability test matrix
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
To=obsv(G.a,G.c);
end

View File

@ -0,0 +1,13 @@
function n=order(G)
% order - extract the order of an FOSS object
%
% n=order(G)
%
% G - an FOSS object
% n - the order
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
n=length(G.a)*G.alpha;
end

22
FOTF Toolbox/@foss/plus.m Normal file
View File

@ -0,0 +1,22 @@
function G=plus(G1,G2)
% plus - evaluate the sum of two FOSS objects, parallel connection
%
% G=G1+G2
%
% G1, G2 - the two FOSS objects in parallel connection
% G - the sum of G1 and G2
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
G1=foss(G1); G2=foss(G2);
if length(G1.alpha)>1 || length(G2.alpha)>1, a=0.0001;
else, a=common_order(G1.alpha,G2.alpha); end
if a==0, G=foss([],[],[],G1.d+G2.d,0);
elseif a<0.001, G1=fotf(G1); G2=fotf(G2); G=foss(G1+G2);
else
G1=coss_aug(G1,round(G1.alpha/a));
G2=coss_aug(G2,round(G2.alpha/a));
G=foss(ss_extract(G1)+ss_extract(G2)); G.alpha=a;
end
end

View File

@ -0,0 +1,12 @@
function rlocus(G)
% rlocus - draw the root locus of a SISO FOSS object
%
% rlocus(G)
%
% G - a SISO FOSS object
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
rlocus(fotf(G))
end

14
FOTF Toolbox/@foss/size.m Normal file
View File

@ -0,0 +1,14 @@
function [p,q,n]=size(G)
% size - extract the numbers of inputs, outputs and states of an FOSS object
%
% [p,q,n]=size(G)
%
% G - an FOSS object
% n, m - the numbers of the inputs and outputs
% n - the number of states
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
q=size(G.c,1); p=size(G.b,2); n=length(G.a);
end

View File

@ -0,0 +1,12 @@
function G1=ss_extract(G)
% ss_extract - extract the SS object from an FOSS object
%
% G1=ss_extract(G)
%
% G - an FOSS object
% G1 - the extracted integer-order state space model
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
G1=ss(G.a,G.b,G.c,G.d); G1.E=G.E;
end

15
FOTF Toolbox/@foss/step.m Normal file
View File

@ -0,0 +1,15 @@
function Y=step(G,varargin)
% step - simulation of an FOSS object driven by step inputs
%
% step(G,t)
%
% G - an FOSS object
% t- the time vector
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
if nargout==0, step(fotf(G),varargin{:});
else, Y=step(fotf(G),varargin{:});
end
end

View File

@ -0,0 +1,13 @@
function G=uminus(G1)
% uminus - unary minus of an FOSS object
%
% G1=-G
%
% G - an FOSS object
% G1- the unary minus of G, i.e., -G
% Copyright (c) Dingyu Xue, Northeastern University, China
% Last modified 28 March, 2017
% Last modified 18 May, 2022
G=G1; G.c=-G1.c; G.d=-G1.d;
end