function q=query query function. prompts for Y/N Y - returns 1 N - returns 0 Michael Loh
0001 function q=query 0002 0003 % function q=query 0004 % 0005 % query function. prompts for Y/N 0006 % 0007 % Y - returns 1 0008 % N - returns 0 0009 % 0010 % Michael Loh 0011 0012 while(~exist('q')) 0013 str=input('(Y/N) ','s'); 0014 str=upper(str); 0015 if (strcmp(str,'Y')) 0016 q=1; 0017 elseif (strcmp(str,'N')) 0018 q=0; 0019 else 0020 disp('Unknown command. Try again'); 0021 end 0022 end