Often you will want to collect input from the user in MATLAB. (This is distinct from collecting keypresses during an experiment, which we learned last week).
For instance, you may want to have your experiment script ask the user for a subject ID at the start of an experiment (other fields may include group, whether to use certain equipment, etc.).
Ask the user for input in the command window as follows:
subID = input('Enter the subject ID: ');
Ask the user for input in a dialog box: (Note that the responses are stored as strings.)
prompt = {'Enter the subject ID: ', 'Enter the group #: '};
name = 'User input';
numLines = 1;
defaultanswer = {'999', '1'};
user_input = inputdlg(prompt, name, numLines, defaultanswer);
subID = str2num(user_input{1});