function restart(script)

%RESTART restart script based on user input
% RESTART(SCRIPT)
% SCRIPT = string containing name of script file to restart

choice = input(['Would you like to repeat ' script...
, ' or stop? [r,q] '], 's');

while(length(choice)~=1 | ~(choice=='r' | choice=='q'))
choice = input('No! You must choose either r or q: ','s');
end

switch(choice)
case 'r'
eval(script); % run script again
case 'q'
disp('Done!');
clear % stop the current program, but not quit MATLAB
otherwise
error('Something is wrong!');
end