home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS1.DI$ / MSCL.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1015 b   |  40 lines

  1. % function out = mscl(mat,fac)
  2. %
  3. %   Scale a SYSTEM/VARYING/CONSTANT by a scalar number.
  4. %   In a SYSTEM matrix, this command scales the B and
  5. %   D matrices by FAC
  6. %
  7. %    out = fac*mat
  8. %
  9. %   See also: *, MMULT, SCLIN, SCLOUT, and SCLIV.
  10.  
  11. function out = mscl(mat,fac)
  12.   if nargin <= 1
  13.     disp('usage: out = mscl(mat,fac)')
  14.     return
  15.   end
  16.   [nrf,ncf] = size(fac);
  17.   if nrf ~= 1 | ncf ~= 1
  18.     error('second argument should be a scalar')
  19.     return
  20.   else
  21.     [mtype,mrows,mcols,mnum] = minfo(mat);
  22.     if mtype == 'vary'
  23.       [vd,rp,indv] = vunpck(mat);
  24.       out = zeros(mrows*mnum+1,mcols+1);
  25.       out(mrows*mnum+1,mcols+1) = inf;
  26.       out(mrows*mnum+1,mcols) = mnum;
  27.       out(1:mnum,mcols+1) = indv;
  28.       out(1:mrows*mnum,1:mcols) = fac*vd;
  29.     elseif mtype == 'syst'
  30.       [a,b,c,d] = unpck(mat);
  31.       out=pck(a,fac*b,c,fac*d);
  32.     elseif mtype == 'cons' 
  33.       out = fac*mat;
  34.     else
  35.       out = [];
  36.     end
  37.   end
  38. %
  39. % Copyright MUSYN INC 1991,  All Rights Reserved
  40.