MATH/CMSC 206 - Introduction to Matlab

Announcements Syllabus Tutorial Projects Submitting

Answers to Self-Test

 1. Calculate the number of seconds in an hour by entering 60 * 60.
60 * 60
ans =

        3600

2. Calculate the number of seconds in a day, making use of your previous answer, ans.

ans * 24
ans =

       86400

3. Create variables called secondsPerYear and initialize it with the correct value making use of your previous answer.

secondsPerYear = ans * 365
secondsPerYear =

    31536000

 4. Create another variable called myAge and set it equal to your age, in years.
myAge = 42;   % put your age here instead of Fawzi's
 5. Save the variables you created in a file called yearVars.
save yearVars
 6. Clear all existing variables. [Look in the Workspace pane to be sure that the variables are really gone.]
clear
 7. Bring back the variables that you stored in the file yearVars.
load yearVars
 8. Using your previous variables, calculate your approximate age, in seconds.
myAge * secondsPerYear
ans =

  1.3245e+009

9. How old is a person when they reach the age of a billion seconds?
1000000000 / secondsPerYear
ans =

   31.7098