% function newsys = sclin(sys,inputs,fac)
%
%   Scale specified inputs (columns) of a SYSTEM (VARYING)
%   matrix by a scalar number FAC.
%
%   See also: *, MMULT, MSCL, SCLOUT, SCLIV and SEL.

function newsys = sclin(sys,inputs,fac)
if nargin < 3
  disp('usage: newsys = sclin(sys,inputs,fac)');
  return
 end
 [nro,nco] = size(inputs);
 [mtype,mrows,mcols,mnum] = minfo(sys);
 if max([nro,nco]) > mcols & min([nro,nco]) > 1
   error('too many inputs (columns) specified')
   return
 end
 [nrf,ncf] = size(fac);
 if nrf == 1 & ncf == 1
   if mtype == 'syst'
     [a,b,c,d] = unpck(sys);
     b(:,inputs) = fac*b(:,inputs);
     d(:,inputs) = fac*d(:,inputs);
     newsys = pck(a,b,c,d);
   elseif mtype == 'cons'
     newsys = sys;
     newsys(:,inputs) = fac*sys(:,inputs);
   elseif mtype == 'empt'
     newsys = [];
   else
     newsys = sys;
     newsys(1:mnum*mrows,inputs) = fac*sys(1:mnum*mrows,inputs);
   end
 else
   error('fac should be a scalar')
   return
 end
 
%
% Copyright MUSYN INC 1991,  All Rights Reserved
