popup_string_to_index.m 473 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
function index = popup_string_to_index(List,String)

% <ITA-Toolbox>
% This file is part of the ITA-Toolbox. Some rights reserved. 
% You can find the license for this m-file in the license.txt file in the ITA-Toolbox folder. 
% </ITA-Toolbox>

List = ['|' List '|'];
String = ['|' String '|'];
tokens = [0 strfind(List,'|')];
StrIdx = strfind(List,String);

if ~isempty(StrIdx)
    index = find(tokens<StrIdx,1,'Last');
else % No Match, StrIdx is empty
    index = 1;
end