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

📄 blkbdemo.m

📁 MFD-多变量系统频域设计工具
💻 M
字号:
% BLKBDEMO  Block Building and Connection Demo for MFD Toolbox.

echo off
%       Dr M.P. Ford 25 Aug 1987. Revised J.M.Maciejowski 21 Dec 1987
% Copyright (c) 1987,1993 by GEC Engineering Research Centre and 
% Cambridge Control Ltd
% History:
%       Made Matlab 4 compatible, 15.7.93, JMM.
%       MR0007, MR0017, MR0018, MR0023, MR0026, MR0036

subplot(1,1,1)
clc

echo on

% This demonstration illustrates the use of
%
%      MVBLKB and MVCON
%
% to produce closed loop step responses for a multivariable system.

% The system and compensators from a Characteristic Locus design 
% will now be loaded in. The design is similar to the one performed 
% in the Characteristic Locus demo, except that the 'Intermediate 
% frequency' Approximate Commutative Controller is in the form of a 
% series connection of 3 blocks, k3,k4,k5, in which k3 and k5 are 
% constant matrices, and k4 is a diagonal transfer function matrix.
% The design also differs in detail.

echo off;
if exist('blkbdata.mat') ~= 2, % If the data file does not exist ...
  disp(' Generating data for demonstration')
  blkbprep;                % ... then generate it.
end
echo on;
load blkbdata
pause % Strike any key to continue
clc
% The system we want to build is this:
%   block
%   numbers   8      7     6       5      4    3    2     1
%
%  u >- + -- k9 - nklow - k5 - n11,d11 - k3 - k2 - k1 - a,b ---.-->--  y
%       |-        dklow        n22,d22                  c,d    |
%       |                                                      |
%       ---------------------------------<----------------------

% First we rename the matrices produced in the Characteristic Locus design
% so that MVBLKB knows what they are and in what order we want them.

num8 = k9; comden8 = 1;           % Final gain adjustment
num7 = nklow; comden7 = dklow;    % Low frequency approx. comm. contr.
num6 = k5; comden6 = 1;                         % These 3 form the
n511 = n11; d511 = d11; n522 = n22; d522 = d22; % intermediate frequency
num4 = k3; comden4 = 1;                         % approx. comm. contr.
num3 = k2; comden3 = 1;           % High - frequency alignment
num2 = k1; comden2 = 1;           % Scaling
a1 = a; b1 = b; c1 = c; d1= d;    % Plant to be controlled

pause % Strike any key to continue
clc

% Lets look at the various block and element names:
%
% The a1,b1,c1,d1 block is the plant.
%
% The numX,comdenX are the MIMO transfer function blocks
% in this example blocks 8,6,4,3 and 2 are pure gains with comdenX = 1.
%
% The n5xx,d5xx are the transfer function elements of block 5. The 
% missing elements (i.e. n512 and n521) are assumed to be zero.

pause % Strike any key to continue
clc

% Now lets set up the matrix and vectors needed by MVBLKB :
%
% TFNBLKS is a matrix describing the MIMO blocks made up of
%    SISO transfer function elements.
%    The first row is the block numbers,
%    the second and third rows are the numbers of inputs and 
%    outputs of that block.

tfnblks=[5
	 2
	 2 ];

% In this example block 5 is a 2 input and 2 output block

pause  % Strike any key to continue
clc

% Ssnblks is a vector containing the block numbers of the 
% state space blocks.
% In this example the only state space block is the plant, block 1.

ssnblks=1;

% Mvnblks is a vector containing the block numbers of the MIMO transfer
%    function blocks.

mvnblks=[2 3 4 6 7 8];

pause % Strike any key to continue
clc

% nblocks is a vector containing the block numbers of SISO
%   transfer function blocks.
%   If nblocks is a scalar then it is turned into a vector by
%   1:nblocks
%   The blocks are specified by nX and dX
%   There are no SISO transfer function blocks in the system so
%   nblocks is not defined.

% In order to check what is going on in MVBLKB the variable
%             verbose
% can be set to 1. If the variable does not exist or is not 1 then
% MVBLKB runs quietly.  Here we will ask to see what is happening.

verbose = 1;

pause % Strike any key to start MVBLKB
clc

echo off  % because `mvblkb' is a script file.
more on
mvblkb
more off
echo on

pause % Strike any key to continue
clc

% Now set up the connection matrix needed by MVCON
% It is straight forward for this example. The blocks are connected 
% in series and there is negative feedback from block 1 to block 8:

q=[ 1 2
    2 3
    3 4
    4 5
    5 6
    6 7
    7 8
    8 -1];

pause  % Strike any key to continue
clc

% The input is to block 8 and the output is from block 1:

iu=8;
iy=1;

% The matrix SZ needed by MVCON has already been produced by MVBLKB.

pause % Strike any key to start MVCON
clc

[aa,bb,cc,dd]=mvcon(a,b,c,d,q,iu,iy,sz);

pause  % Strike any key to continue
clc

% Check the condition number of the `A' matrix:

disp(['Condition number = ',num2str(cond(aa))])

% Use BALREAL to improve it.  NOTE this is only possible because
% MVCON has removed all the zero eigenvalues which were due to the
% pure gains in the system.
% The balancing may take some time on certain machines.

[aa,bb,cc]=balreal(aa,bb,cc);

disp(['Condition number = ',num2str(cond(aa))])
% Note the improved condition number.

pause % Strike any key to continue
clc

pack  % to make more space in memory

% Now we will calculate the step responses

t = [0:2:500]/100;
y1=step(aa,bb,cc,dd,1,t); % Responses to step demand on output 1
y2=step(aa,bb,cc,dd,2,t); % Responses to step demand on output 2

      % Strike any key to plot the responses.
      % The solid red line is the response of output 1.
pause % The dashed green line is the response of output 2.

subplot(2,1,1)
plot(t,y1(:,1),'-r',t,y1(:,2),'--g'),
title('Response to step demand on output 1')
xlabel('Seconds')

subplot(2,1,2)
plot(t,y2(:,1),'-r',t,y2(:,2),'--g')
title('Response to step demand on output 2')
xlabel('Seconds')

% End of Demo

pause % Strike any key to return to the Main Menu.

subplot(1,1,1)
echo off

⌨️ 快捷键说明

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