translateList

PURPOSE ^

translateList Translate a list of identifiers (either numerical or cell

SYNOPSIS ^

function list = translateList(list,trList1,trList2)

DESCRIPTION ^

translateList Translate a list of identifiers (either numerical or cell
array) using a dictionary

 list = translateList(list,trList1,trList2)

 Usage:

 Define original list

 list = {'a','b','c'}

 Define dictionary

 trList1 = {'b','c'} 
 trList2 = {'B','C'}

 newList = translateList(list,trList1,trList2);
 
 returns

 newList = {'a','B','C'};

 Markus Herrgard 8/17/06

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function list = translateList(list,trList1,trList2)
0002 %translateList Translate a list of identifiers (either numerical or cell
0003 %array) using a dictionary
0004 %
0005 % list = translateList(list,trList1,trList2)
0006 %
0007 % Usage:
0008 %
0009 % Define original list
0010 %
0011 % list = {'a','b','c'}
0012 %
0013 % Define dictionary
0014 %
0015 % trList1 = {'b','c'}
0016 % trList2 = {'B','C'}
0017 %
0018 % newList = translateList(list,trList1,trList2);
0019 %
0020 % returns
0021 %
0022 % newList = {'a','B','C'};
0023 %
0024 % Markus Herrgard 8/17/06
0025 
0026 [isInList,listInd] = ismember(list,trList1);
0027 
0028 list(isInList) = trList2(listInd(listInd ~= 0));

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003