Home > freetb4matlab > set > ismember.m

ismember

PURPOSE ^

% Return a matrix @var{tf} the same shape as @var{A} which has 1 if

SYNOPSIS ^

function [tf, a_idx] = ismember (a, s, rows_opt)

DESCRIPTION ^

% -*- texinfo -*-
% @deftypefn {Function File} {[@var{tf}, @var{a_idx}] =} ismember (@var{A}, @var{S}) 
% @deftypefnx {Function File} {[@var{tf}, @var{a_idx}] =} ismember (@var{A}, @var{S}, 'rows')
% Return a matrix @var{tf} the same shape as @var{A} which has 1 if 
% @code{A(i,j)} is in @var{S} or 0 if it isn't.  If a second output argument 
% is requested, the indexes into @var{S} of the matching elements are
% also returned. 
%
% @example
% @group
% a = [3, 10, 1];
% s = [0:9];
% [tf, a_idx] = residue (a, s);
%      @result{} tf = [1, 0, 1]
%      @result{} a_idx = [4, 0, 2]
% @end group
% @end example
%
% The inputs, @var{A} and @var{S}, may also be cell arrays.
%
% @example
% @group
% a = @{'abc'@};
% s = @{'abc', 'def'@};
% [tf, a_idx] = residue (a, s);
%      @result{} tf = [1, 0]
%      @result{} a_idx = [1, 0]
% @end group
% @end example
%
% With the optional third argument @code{'rows'}, and matrices 
% @var{A} and @var{S} with the same number of columns, compare rows in
% @var{A} with the rows in @var{S}.
%
% @example
% @group
% a = [1:3; 5:7; 4:6];
% s = [0:2; 1:3; 2:4; 3:5; 4:6];
% [tf, a_idx] = ismember(a, s, 'rows');
%      @result{} tf = logical ([1; 0; 1])
%      @result{} a_idx = [2; 0; 5];
% @end group
% @end example
%
% @seealso{unique, union, intersect, setxor, setdiff}
% @end deftypefn

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Sat 16-May-2009 00:04:49 by m2html © 2003