MATLAB project

profileu.wq8
cs_122_project_2.doc

image1.png Project 2: Symbolic Math

CS 122 • 15 Points total

Objective

Practice symbolic math commands in MATLAB as well as MuPAD to solve a problem.

Discovery

Review the video we showed in class: http://www.mathworks.com/products/symbolic/

Also, please review this web site: http://www.mathworks.com/discovery/mupad.html

One professor at the University of Maryland put together a nice tutorial at:

http://www2.math.umd.edu/~immortal/206/tutorial/Mupad_1.shtml

Try this (to run MuPAD): from the MATLAB main screen, click on “Apps”, then “MuPAD Notebook” ( “General Math” ( “Solve” ( “Exact” and just briefly review the functionality of the “MuPAD Notebook” that is available in MATLAB. (Note that the “General Math” button is off to the right.)

Assignment Note

Note that all of the NAU Engineering computers (including the remote desktop servers) should have MATLAB with "symbolic math" commands, but other installations of MATLAB may or may not have them.

Problem Statement

A brand of plastic squirt bottle indicates that it holds 8 oz of fluid. The bottle is in the shape of a tapered cylinder (or conic section). The following measurements are made:

Base diameter: 2.625" Top diameter: 1.275" Height: 4.5"

Use MATLAB (and math!) to determine whether the bottle's capacity is accurate - does it indeed hold 8 ounces?

Approach

We will use algebra to find an equation that describes the diameter of the bottle anywhere along its height. Given the correct diameter we can find the area of the bottle at any arbitrary height, so then we use calculus obtain the total volume of the bottle by summing the area of each infinitely-thin slice of bottle from height=0" to height=4.5".

Diameter Function

The bottle is 2.625" in diameter at height h=0 and then linearly decreases its diameter until it becomes 1.275" in diameter at height h=4.5". Let's find the constant factor k that indicates how the diameter shrinks as the height increases. Type this into MATLAB:

f = sym( '2.625 - k*4.5 = 1.275' )

solve( f, 'k' )

This will give you an actual value for k. Use this value for k in "Area of a Slice", below.

Diameter Function

The function that describes the diameter at a given height h is diameter(h) = 2.625 - k×h. You do not need to type in anything yet.

Area of a Slice

The area of an infinitely-thin circle is π×r2 or pi×(1/2d)2. Let's define the function for the area of a bottle slice at height h with the following MATLAB command:

area = sym( 'pi * (0.5*(2.625 - k * h)) ^ 2' )

Type this in using the actual value we discovered for k in place of it.

Bottle Volume

Now integrate the area of a slice of bottle over the full bottle height from h=0" to h=4.5":

int( area, 'h', 0, 4.5 )

This is the volume of the bottle in cubic inches. Look up the conversion factor for cubic inches to fluid ounces online and use MATLAB to convert the cubic inches (type actual numeric values for both of the following):

cubic_inches * cubic_inches_to_fluid_ounces_factor

You should get about (but not exactly) 8 oz as your answer.

Now try the same problem in MuPAD

The syntax for MATLAB is different than what you have learned this semester using the MATLAB command line or creating a MATLAB script. Try playing with it first to get comfortable. Then, try pasting the above expressions to get the same result using MuPAD.

At the MATLAB command window, to use MuPAD, you can do what was stated above (in the “Discovery” section), or just type >>mupadwelcome, then select “New Notebook” to get started. Save your MuPAD notebook (using File ( Save As).

Below is a sample screen shot of what your MuPAD result could be:

image2.png

Project Report

The final step of this assignment is to create a Project Report (Word document) in the format you did for CS122 (lecture) Project 1.

The Project Report should contain the following information:

1. Purpose Describe the purpose of your program.

2. Approach Describe your approach to completing this project.

You will be entering commands at the MATLAB command line (or building an “.m” file) as instructed above. You will also be creating an MuPAD notebook file (“.mn”) of the same solution and result.

3. Methods

Mathematical processes followed.

4. Implementation

Results and output of the command window or “.m” file (including pasting the commands you typed in). Also show the contents of your MuPAD “.mn” file that would execute the result in the sample screenshot. Use comments in your code to explain your work.

5. Conclusions

Describe any significant problems or challenges you encountered and how you solved them.

Submit your results (Project Report) in the correct place in Blackboard Learn ( http://bblearn.nau.edu ) by the due date.