function mtc = match(LIST,element) % match(LIST,element) -- Find the position of an element in a list. % % Given a single row vector LIST, find out which item % in the list matches. Return that number. This function % is conceptually based on the match() function in PennMUSH. Like % PennMUSH match(), it only finds the FIRST instance of a number. % must be an array of characters, such as LIST = ['a' 'b' 'c',...] % must be in character form % % Example: % >> m = match(['a' 'b' 'c' 'd' 'e' 'f'],'c') % m = 3 listsize = size(LIST,2); position = 0; % position 0, reserved for non-matches for i = 1:listsize if (LIST(i) == element) position = i; break; end end mtc = position; % the position number, for output from the function