home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SPARFUN.DI$ / SPONES.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  299 b   |  11 lines

  1. function R = spones(S);
  2. %SPONES    Replace nonzero entries with ones.
  3. %    R = SPONES(S) generates a matrix with the same sparsity
  4. %    structure as S, but with ones in the nonzero positions.
  5.  
  6. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  7.  
  8. [i,j] = find(S);
  9. [m,n] = size(S);
  10. R = sparse(i,j,1,m,n);
  11.