function object = getList(list,name); %getList - get an object from a list based on the name of the objects. % % Parameter: list The list to be searched % Parameter: name Name to search for % Returns: object The object found % % Example(s): % tfplan = getList(ex.tflist,'Zipper'); % %% =========================================================================== %% =========================================================================== % Copyright (C): % 1999 by Telia Research AB, Lulea, Sweden; % 2000-2002 by Forschungszentrum Telekommunikation Wien, Austria; % All rights reserved. % Project : The FTW simulator % Author(s) : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % : Daniel Bengtsson (Daniel.J.Bengtsson@Telia.se) % : Steffen Trautmann (trautmann@ftw.at) % % CVS: $Id: getList.m,v 1.5 2002/01/25 12:43:32 tono Exp $ %% =========================================================================== % Change History % 1999-02-25 (ToNo) Created % 2002-01-17 (StTr) Slow 'for'-loop replaced by equivalent code %% =========================================================================== found_idx=find(strcmp({list.name},name)); %Check if we found anything and take care of multiple entries if isempty(found_idx) warning(sprintf('Object %s not found in the list!', name)); object=[]; else len_found_idx=length(found_idx); if len_found_idx>1 warning(sprintf('There are multiple entries of object %s in the list!', name)); end % Choose first entry if list has multiple entries with the same name % object=list(found_idx(1)); % Choose last entry if list has multiple entries with the same name % (for full compatibility to old version) object=list(found_idx(len_found_idx)); end