MATH/CMSC 206 - Introduction to Matlab

Announcements Syllabus Tutorial Projects Submitting

Answers to Self-Test

1. Consider a right-triangle with one "leg" of length 13, and the other "leg" of length 27. Write a single MATLAB command that you could use to compute the length of the hypotenuse.

sqrt(13^2 + 27^2)
ans =

   29.9666

2. Write a single MATLAB command that would compute the area of a circle having a radius of 73

pi * 73^2
ans =

  1.6742e+004

3. Write a single MATLAB command that will compute the number of seconds there are in 1 year (assuming there are 365 days per year).

Considering that there are 60 seconds in a minute, 60 minutes in an hour, 24 hours in a day, and 365 days in a year, we came up with:

60 * 60 * 24 * 365
ans =

    31536000

4. You are standing on the ground, pointing to a window that is high above the ground and far away. The angle between the ground and your outstretched arm is .5 radians. The length of the direct line from your finger to the window is 392 feet. Write a single MATLAB command that will compute the height of the window above the ground.

This problem describes a right-triangle, with one leg running along the ground from yourself to the building, another leg running up the building from the ground to the window, and the hypotenuse being the line from your finger to the window. We know the length of the hypotenuse and the angle where we are standing, and we are looking for the length of the leg that is opposite this angle -- let's call it "x". Now we can employ the definition of the sin function which gives us: sin(.5) = x / 392. Solving for x, we get:

sin(.5) * 392
ans =

  187.9348