GETFLAG Check the presence of a flag in an argument list OPTION=GETFLAG(ARGS,OPTNAME) Return a logical value indicating the presence of the flag name in the argument list. Flag names are case insensitive. ARGS: Argument list (cell array) OPTNAME: Name of the desired option (string) [OPTION,NEWARGS]=GETFLAG(ARGS,OPTNAME) Returns the argument list after removing the processed flag Dee also GETOPTION
0001 function [flag,opts] = getflag(opts,optname) 0002 %GETFLAG Check the presence of a flag in an argument list 0003 % 0004 %OPTION=GETFLAG(ARGS,OPTNAME) 0005 % Return a logical value indicating the presence of the flag name in the 0006 % argument list. Flag names are case insensitive. 0007 % 0008 %ARGS: Argument list (cell array) 0009 %OPTNAME: Name of the desired option (string) 0010 % 0011 %[OPTION,NEWARGS]=GETFLAG(ARGS,OPTNAME) 0012 % Returns the argument list after removing the processed flag 0013 % 0014 %Dee also GETOPTION 0015 0016 ok=strcmpi(optname,opts); 0017 flag=any(ok); 0018 opts=opts(~ok); 0019 end 0020