MATLAB: How to take a user input and use that in an equation

equationhelpuser input

I am writing a code to ask the user a series of questions. Once they enter their time I want to calculate that amount of time into hours. How do I take the user input and put that into an equation?
n=input('Are you entering in milliseconds or seconds? Enter 1 for milliseconds or 2 for seconds. ');
if n==1;
disp('Enter time in ms: ');
else n==2;
disp('Enter time in sec: ');

Best Answer

units_opts = {'milliseconds', 'seconds', 'fortnights'};
units_ms_scale = [1 1000 14*24*60*60*1000];
n = menu('Time units:', units_opts);
if n < 1; return; end %user cancel
user_entered_time = input( sprintf('Enter the time, in %s', units_opts{n}) );
user_time_ms = user_entered_time * units_ms_scale(n);