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

  1. % function vout = vdcmate(vin,spacing)
  2. %
  3. %   The input VARYING matrix is decimated; i.e the output only
  4. %   contains the input at the points specified by spacing.  If no
  5. %   spacing argument is provided, the default is 10, in honour of
  6. %   the original Roman punishment.
  7. %
  8. %   See also: DECIMATE, GETIV, SEL, VPCK and VUNPCK. 
  9.  
  10. function vout = vdcmate(vin,spacing)
  11.  
  12. if nargin ~= 1 & nargin ~= 2,
  13.     disp('usage: vout = vdcmate(vin,spacing')
  14.     return
  15.     end
  16.  
  17. if nargin == 1,
  18.     spacing = 10;
  19.     end
  20.  
  21. [type,nr,nc,npts] = minfo(vin);
  22. if type == 'syst',
  23.     error('cannot decimate a SYSTEM matrix')
  24.     return
  25.     end
  26.  
  27. if type == 'cons',
  28.     vout = vin;
  29.     return
  30. else
  31.     [data,ptr,iv] = vunpck(vin);
  32.     ivsel = [0:spacing:npts-1];
  33.     npts = length(ivsel);
  34.     index = ones(nr,1)*(ivsel*nr) + [1:nr]'*ones(1,npts);
  35.     index = reshape(index,npts*nr,1);
  36.     vout = zeros(npts*nr+1,nc+1);
  37.     vout(1:npts*nr,1:nc) = data(index,:);
  38.     vout(nr*npts+1,nc+1) = inf;
  39.     vout(nr*npts+1,nc) = npts;
  40.     vout(1:npts,nc+1) = iv(ivsel+1);
  41.     end
  42.  
  43. %--------------------------------------------------------------------------
  44.  
  45. %
  46. % Copyright MUSYN INC 1991,  All Rights Reserved
  47.