Home > TNNT_1_07 > Stack > push_unique.m

push_unique

PURPOSE ^

PUSH_UNIQUE adds values to the stack tail for values not already present

SYNOPSIS ^

function Stack=push_unique(Stack,Vals)

DESCRIPTION ^

PUSH_UNIQUE adds values to the stack tail for values not already present

Description:
Function to add values to the stack tail for values not already in the
stack.

Syntax:
Stack=PUSH_UNIQUE(Stack,Vals);

Input Parameters:
o Stack: A one-dimensional column vector used to store neuron indices.
o Vals: A one-dimensional column vector (may be scalar) of neuron indices 
    to be added to the Stack.

Output Parameters:
o Stack: A one-dimensional column vector used to store neuron indices.

Example:
>> Stack=[1; 3; 4];
>> Stack=push_unique(Stack,[1; 5; 2])

See also theta_neuron_network

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function Stack=push_unique(Stack,Vals)
0002 %PUSH_UNIQUE adds values to the stack tail for values not already present
0003 %
0004 %Description:
0005 %Function to add values to the stack tail for values not already in the
0006 %stack.
0007 %
0008 %Syntax:
0009 %Stack=PUSH_UNIQUE(Stack,Vals);
0010 %
0011 %Input Parameters:
0012 %o Stack: A one-dimensional column vector used to store neuron indices.
0013 %o Vals: A one-dimensional column vector (may be scalar) of neuron indices
0014 %    to be added to the Stack.
0015 %
0016 %Output Parameters:
0017 %o Stack: A one-dimensional column vector used to store neuron indices.
0018 %
0019 %Example:
0020 %>> Stack=[1; 3; 4];
0021 %>> Stack=push_unique(Stack,[1; 5; 2])
0022 %
0023 %See also theta_neuron_network
0024 
0025 %Copyright (C) 2008 Sam McKennoch <Samuel.McKennoch@loria.fr>
0026 
0027 
0028 if ~isempty(Stack)
0029     
0030     for j=1:length(Vals)
0031         if ~max(Vals(j)==Stack)
0032             Stack=[Stack; Vals(j)];
0033         end
0034     end
0035 %    %Inline ~ismember(Vals,Stack)
0036 %    Temp=false(1,length(Vals));
0037 %    for j=1:length(Vals)
0038 %        Temp(j)=(~max(Vals(j)==Stack));
0039 %    end
0040 
0041 %    Stack=[Stack; Vals(Temp)];%Vals(~ismember(Vals,Stack))];
0042 else
0043     Stack=Vals;
0044 end
0045

Generated on Wed 02-Apr-2008 15:16:32 by m2html © 2003