[Index for tmp_for_tar/misc] [Return to Master Index]

loose

(tmp_for_tar/misc/loose.m)


Function Synopsis

X = loose(indice,sz,cont,rowcol) 

Help text

 X = loose (indice [,sizeX,content,rowcol]) - contrary of find

 indice  : P    or : List of indexes
           Px2  or   List of [row, column]
           2xP  or   List of [row; column]
           PxQ  or   List of indices (same as indice(:))

 sizeX   : 2    or : Size of X
           1         Same as [sizeX(1),1]      Default = max(indice)

 content : 1    or
           number of indexes                   Default = ones

 rowcol  : 1         If defined and true (resp. false), use
                     "row-column" (resp. "index list") interpretation
                     of  'indice'. Default is to choose "row-column"
                     iff 'indice' is a 2xP or Px2 (for P>1).

 Returns X such that X(indice) == content.

 Indices outside of the range specified in sizeX are ignored.

 Mnemonic : 'loose' is the contrary of 'find'

 Last modified: April 2001



Listing of function file tmp_for_tar/misc/loose.m

## X = loose (indice [,sizeX,content,rowcol]) - contrary of find
##
## indice  : P    or : List of indexes
##           Px2  or   List of [row, column]
##           2xP  or   List of [row; column]
##           PxQ  or   List of indices (same as indice(:))
##
## sizeX   : 2    or : Size of X
##           1         Same as [sizeX(1),1]      Default = max(indice)
##
## content : 1    or
##           number of indexes                   Default = ones
##
## rowcol  : 1         If defined and true (resp. false), use
##                     "row-column" (resp. "index list") interpretation
##                     of  'indice'. Default is to choose "row-column"
##                     iff 'indice' is a 2xP or Px2 (for P>1).
## 
## Returns X such that X(indice) == content.
##
## Indices outside of the range specified in sizeX are ignored.
## 
## Mnemonic : 'loose' is the contrary of 'find'
##

## Author:        Etienne Grossmann  <etienne@isr.ist.utl.pt>
## Last modified: April 2001

function X = loose(indice,sz,cont,rowcol) 


				# Guess size 
if nargin<2, sz = max(indice) ; end

				# Guess second dimension
if prod(size(sz))==1,sz(2)=1 ; end

## keyboard
				# Make indices from row and column.
if any (size (indice)==2) && all (sz>=2) && (nargin<4 || rowcol), 
  indice = ind2sub (sz, indice)  
end
if any (indice > prod (sz)),
  keep = find (indice<=prod(sz));
  if nargin>=3 && all (size (cont) == size (indice)),
    cont = cont(keep);
  end
  indice = indice(keep);
end

X = zeros(sz) ;
				# Guess contents
if nargin<3, X(indice(:)) = 1 ; 
else         X(indice(:)) = cont ;
end



Produced by oct2html on Sat Apr 28 21:14:54 2001
Cross-Directory links are: ON