Code covered by the BSD License  

Highlights from
waitinput

5.0

5.0 | 2 ratings Rate this file 5 Downloads (last 30 days) File Size: 1.98 KB File ID: #28881

waitinput

by Grzegorz Knor

 

29 Sep 2010

WAITINPUT Prompt for user input, but no longer than t seconds.

| Watch this File

File Information
Description

%WAITINPUT Prompt for user input, but no longer than t seconds.
% output = WAITINPUT('Input something',t) gives the user the prompt in the
% text string and then waits for input from the keyboard by t seconds.
% R is the result. When user not specified s argument R will be a double,
% or if argument s i s eqal to 's', R will be a char. For other s
% argument function return an error.
% Function works only with alphanumeric characters.
%
% Example:
% waitinput('what is your name? ',10,'s')
%
% This function is inspired by Matlab INPUT function and GetKeyWait by
% Jos (10584) from File Exchange:
% http://www.mathworks.com/matlabcentral/fileexchange/8297-getkeywait
%
% See also INPUT, KEYBOARD.
%
% Copyright 2010 Grzegorz Knor

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
getkey, GetKeyWait

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
05 Aug 2011 Grzegorz Knor

In line 37 should be:
error('The third argument to WAITINPUT must be ''s'', or ''d''.')

Instead of:
error('The second argument to WAITINPUT must be ''s'', or ''d''.')

01 Sep 2011 mohammad  
01 Sep 2011 mohammad  
01 Sep 2011 mohammad

thanks a lot. works perfect!!!

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
input Grzegorz Knor 29 Sep 2010 11:35:24
getkey Grzegorz Knor 29 Sep 2010 11:35:24
keypress Grzegorz Knor 29 Sep 2010 11:35:24
keyboard Grzegorz Knor 29 Sep 2010 11:35:25

Contact us at files@mathworks.com