1 function [outUnqVec,indRightToLeftVec,indLeftToRightVec]=
uniquebyfunc(inpVec,fCompare,algoName)
5 DEFAULT_ALGO_NAME=
'mempreserve';
8 algoName=DEFAULT_ALGO_NAME;
16 [isThereVec,indLeftToRightVec]=
ismemberbyfunc(inpVec,inpVec,fCompare); %#ok<ASGLU>
17 indVec=1:numel(indLeftToRightVec);
20 indLeftToRightVec=indLeftToRightVec.';
23 isInUniq=
ismember(indVec,indLeftToRightVec);
24 indRightToLeftVec=find(isInUniq);
25 [isThereVec,indLeftToRightVec]=
ismember(indLeftToRightVec,...
26 indRightToLeftVec); %#ok<ASGLU>
27 outUnqVec=inpVec(isInUniq);
29 % more memory preserving
32 indLeftToRightVec=nan(numel(inpVec),1);
33 for iObj=1:numel(inpVec)
34 [isThereVec,indThereVec]=
ismemberbyfunc(inpVec(iObj),outUnqVec,fCompare);
36 outUnqVec=[outUnqVec; inpVec(iObj)]; %#ok<AGROW>
37 indRightToLeftVec=[indRightToLeftVec; iObj]; %#ok<AGROW>
38 indLeftToRightVec(iObj)=length(outUnqVec);
40 indLeftToRightVec(iObj)=indThereVec;
44 outUnqVec=outUnqVec.
'; 47 throwerror('wrongInput
','algorithm %s is not supported
',algoName);
function ismemberbyfunc(in leftVec, in rightVec, in fCompare)
ISMEMBERBYFUNC - ismember implementation for arrays of any type where an element comparison is perfor...
function ismember(in leftVec, in rightVec, in varargin)
ISMEMBER - ismember implementation for arrays of any type.
function uniquebyfunc(in inpVec, in fCompare, in algoName)
UNIQUEBYFUNC unique for arrays of any type where an element comparison is performed by a specified fu...
function isrow(in inpArray)