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

  1. % function [vout] = scliv(vin,fac,offset)
  2. %
  3. %   Scale the independent variable elements of a varying matrix by FAC
  4. %   and adds the OFFSET (optional) to each. i.e.
  5. %
  6. %    newiv = fac*oldiv + offset.
  7. %
  8. %   This does nothing for a CONSTANT matrix and returns an error
  9. %   for a SYSTEM matrix.
  10. %
  11. %   See also: *, MMULT, MSCL, SCLIN, SCLOUT, and SEEIV.
  12.  
  13. function [vout] = scliv(vin,fac,offset)
  14. if nargin ~= 2 & nargin ~= 3,
  15.     disp('usage: vout = scliv(vin,fac,offset)')
  16.     return
  17.     end
  18.  
  19. [type,nr,nc,npts] = minfo(vin);
  20. if type == 'syst',
  21.     error('cannot scale independent variable for a SYSTEM')
  22.     return
  23.     end
  24.  
  25. if nargin == 2,
  26.     offset = 0;
  27.     end
  28.  
  29. [i,j] = size(fac);
  30. if i ~= 1 | j ~= 1,
  31.     error('scaling factor must be a scalar')
  32.     return
  33.     end
  34.  
  35. if type == 'vary',
  36.     iv = getiv(vin);
  37.     iv = offset + fac*iv;
  38.     vout = vin;
  39.     vout(1:npts,nc+1) = iv;
  40. else
  41.     vout = vin;
  42.     end
  43.  
  44. %--------------------------------------------------------------------------
  45.  
  46.  
  47. %
  48. % Copyright MUSYN INC 1991,  All Rights Reserved
  49.