home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 10.ddi / CONTROL.DI$ / ABCDCHK.M next >
Encoding:
Text File  |  1993-03-11  |  1.1 KB  |  40 lines

  1. function msg = abcdchck(a,b,c,d)
  2. %ABCDCHK Checks dimensional consistency of A,B,C,D matrices.
  3. %    MSG = ABCDCHK(A,B,C,D) checks the consistency of the dimensions 
  4. %    of A,B,C,D.  Returns the empty matrix if they are, or an
  5. %    an error message string if they are not.
  6. %
  7. %    Valid systems with empty matrices are allowed.  
  8.  
  9. %     J.N. Little 3-24-85
  10. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  11. %    Revised 2-25-88 JNL, 6-26-90 CMT, 2-14-91 ACWG
  12.  
  13. msg = [];
  14. [ma,na] = size(a);
  15. if (ma ~= na)
  16.     msg = 'The A matrix must be square';
  17. end
  18. if (nargin > 1)
  19.     [mb,nb] = size(b);
  20.     if (ma ~= mb)&nb
  21.     msg = 'The A and B matrices must have the same number of rows.';
  22.     end
  23.     if (nargin > 2)
  24.         [mc,nc] = size(c);
  25.         if (nc ~= ma)&mc
  26.      msg = 'The A and C matrices must have the same number of columns.';
  27.         end
  28.         if (nargin > 3)
  29.             [md,nd] = size(d);
  30.             if ((ma+mb+mc) == 0), return, end
  31.             if (md ~= mc)&(nd | nb)
  32.     msg = 'The C and D matrices must have the same number of rows.';
  33.             end
  34.             if (nd ~= nb)&(md | mc)
  35.     msg = 'The B and D matrices must have the same number of columns.';
  36.             end
  37.         end
  38.     end
  39. end
  40.