Você está na página 1de 6

ENGR 13200 Ideas to Innovations Part II Spring 2011

HOMEWORK #4
Due: Class 4b

To be submitted in Class 4B:


Individually:
1. Hardcopy printout of your function m-files, fxy4C_yourlogin.m and
fxy4F_yourlogin.m.
2. Hardcopy printout of your function m-file, Class3b_Activity5.m.
3. Hand written answers to problem 3.
4. Hardcopy printout of your function m-file, asin_yourlogin.m.
5. Flowchart and hardcopy printout of your function m-file, phases_yourlogin.m.
Team:
1. Hardcopy printout of your Team Flyer.
2. Hardcopy printout of your Code of Cooperation signed by each team member.

To be submitted electronically before Class 4B:


Individually:
1. Your function m-files, fxy4C_yourlogin.m and fxy4F_yourlogin.m.
2. Your function m-file, Class3b_Activity5.m.
3. Your function m-file, asin_yourlogin.m.
4. Your function m-file, phases_yourlogin.m.
Team:
1. Team Flyer.

0. Reading Assignment
Ideas to Innovation Textbook:
Chapter 26: pp. 589-597.

Mathworks Tutorials (Optional but Recommended): Much (but not all) of the content
in the above reading is represented visually in the following Interactive MATLAB
Tutorial materials available through the MathWorks website,
www.mathworks.com/purduefirstyear/matlabtutorial. The recommended segments for
this week are:
Programming in MATLAB
 Flow and Loop Control
o Flow Control
o Writing Conditional Statements
ENGR 13200 Ideas to Innovations Part II Spring 2011

1. MATLAB In-Class Activity


This is to be completed individually.
This problem is added to your homework grade.

Complete activity 4 from class 3b.

Deliverable: Hardcopy printout of your function files, fxy4C_yourlogin.m and


fxy4F_yourlogin.m. Upload your m-files to your Faculty Instructor’s Assignment Drop
Box on Blackboard.

2. MATLAB In-Class Activity


This is to be completed individually.
This problem is added to your homework grade.

Complete activity 5 from class 3b.

Deliverable: Hardcopy printout of your function file, Class3b_Activity5.m. Upload your


m-file to your Faculty Instructor’s Assignment Drop Box on Blackboard.

3. Debugging a User-defined Function


This is to be completed individually.
This problem is part of your homework grade.
The following user-defined function M-file (cone_calcs.m) was created
by a student in ENGR 13200 to compute the volume and area of a right-
circular cone.

Line
Code
#
1 function [vol,area] = cone_calcs(r,h)
2 % This function computes the volume and surface area
3 % of a right-circular cone.
4 % INPUTS: the scalar radius r of the circular base
5 % the scalar height h of the cone
6 % OUTPUTS: the scalar volume V of the cone
7 % the scalar area A of the cone
8
9 if r=<0 || h<=0
10 error(‘The cone must have positive dimensions’)
11
12 base = pi*r^2; % area of base circle
13 sides = pi*r*sqrt(r^2 + H^2); % area of the sloped sides
14 else if
15 V = 1/3*base*H; % volume
16 A = sides + base; % total surface area
17 end
18
ENGR 13200 Ideas to Innovations Part II Spring 2011

1. What does she/he need to type in the MATLAB Command window to run this user-
defined function for a cone with a height of 4 cm and radius of 3 cm?

>>

2. When you type the command from step 1, it results in an error message. Identify
THREE (3) errors in the code using the table below. Clearly indicate the line number
of the error, describe the error and how it could be fixed. Each error counts as one,
even if there are multiple errors on the same line.
Line number What is the error? How could it be fixed?

Deliverables: A hard copy printout of the command to run the user-defined function
and the three errors identified above.

4. User-Defined Function – error checking


This problem is to be completed individually.
This problem is added to your homework grade.

1. Open function_header_template.m in the MATLAB editor and re-save as


asin_yourlogin.m. Edit the header as appropriate for the problems below.
2. Complete Textbook problem 26.11 (p. 621-2) and additions indicated below in this
function file.
a. Name your function asin_yourlogin rather than my_asin as stated in the problem.
If the input value is not between -1 and 1, the output variable should return the
string ‘value must be between -1 and 1’.
b. Test your function at the command line using the following test cases. Using
comments in the OUTPUT section of your function, paste what is displayed by
your function.
i. x = 0.5
ii. x = -1.9
iii. x = 0
iv. x = 3

Deliverable: Hardcopy printout of your function file, asin_yourlogin.m. Upload your


m-file to your Faculty Instructor’s Assignment Drop Box on Blackboard.
ENGR 13200 Ideas to Innovations Part II Spring 2011

5. MATLAB Phase Diagram Processing


This is to be completed individually.
This problem is added to your homework grade.

At the right, a phase diagram has been simplified


by replacing all curved lines with straight lines.
For this phase diagram (not drawn to scale):
• the melting point of pure A is 630 °C.
• the melting point of pure B is 750 °C.
• the eutectic line is at 300 °C and the eutectic
point occurs at 35% B.
• the ends of the eutectic line are at 15% B and
80% B.

Write a MATLAB function that determines the correct phases that may exist for a given
mass % of B and temperature. The input arguments for the function are the mass % of B
and the temperature. There are no output arguments for this function.
1. Draw a flowchart that uses conditional statements to determine the correct phases
based upon the mass % of B and the temperature.
2. Open the function_header_template.m file in the MATLAB editor and save as
phases_yourlogin.m. Modify the Comments section for this problem.
3. Under the INPUT section of your function, assign the values in the problem statement
that determine the phase boundaries which are fixed (and not known to most users).
4. Under the CALCULATION section:
a. Use conditional statements to check that the user has entered valid inputs.
b. Use conditional statements to direct the program to the correct phase based on the
composition and temperature entered.
5. Under the OUTPUT section, use the fprintf command to restate the input values and
display the result formatted as:
“For ##.# mass % B at ###.# degrees C, the phase is your phase result.”
Remember to indicate if the provided conditions are on the eutectic line or at the
eutectic point.
6. Test your function at the command line using the following test cases. Using
comments in the OUTPUT section of your function, paste what is displayed by your
function (if you turn in results you know are wrong, please say so and indicate what is
not working properly):
a. 400 °C, 12% B c. 280 °C, 60% B
b. 300 °C, 35% B d. 100 °C, 110% B
ENGR 13200 Ideas to Innovations Part II Spring 2011

Deliverables:
1. Flowchart for your function from step 1.
2. Hardcopy printout of your phases_yourlogin.m file.
3. Electronic submission of your phases_yourlogin.m file to your Faculty Instructor’s
Assignment Drop Box on Blackboard.

6. ENGR 13200 Teaming Concepts - Team Flyer


This problem is to be completed by your entire team.
This problem is added to your Team Participation grade.
Make a one-page team flyer (a flyer is an unfolded 8 ½ x 11 sheet with copy on only one
side). Note that your instructional team may carry copies of your team fliers around all
semester to help them learn names and remind them of who is on your team. Some
professors are known to pull out their set of team fliers every time they get email from
their students! Therefore, your flier should include your team member names clearly
matched to photos of your team members. Also, include something personal about your
team and team members that helps your team stand out.
Deliverable: Hardcopy printout of your team flyer. Upload your team flyer to your
Faculty Instructor’s Assignment Drop Box on Blackboard.

7. ENGR 13200 Teaming Concepts – Code of Cooperation


This problem is to be completed by your entire team.
This problem is added to your Team Participation grade.
Your team's assignment is to develop a Code of Cooperation with a set of rules provided
and at least five (5) additional rules that your team will create. You will use your
Code of Cooperation to hold your team and individual members accountable. The rules
you will create are of two types: team and individual. Team rules are targeted at
keeping the team as a whole accountable; individual rules are targeted at keeping
individuals accountable. Your team must develop at least one of each type. Each rule
should be worded appropriately to allow future evaluation of your team and team
members on a scale of strongly agree to strongly disagree. It should indicate how roles
will rotate, how meeting times will be determined and announced, include other
important aspects of how your team will communicate and accomplish its work and
courses of action for when the rules are broken. When you access your on-line Code of
Cooperation, you will see the list of rules we are providing. Use these as a guide when
creating your team rules.
To electronically submit your Code of Cooperation, one team member must go to the on-
line assignment page at:
https://engineering.purdue.edu/ENE/WebformsFor/AvailableFor/engr132_11sp
After logging in, select Code of Cooperation from the Available Forms list. Verify that
all team members’ names are correct at the top of the Code of Cooperation accessed. All
ENGR 13200 Ideas to Innovations Part II Spring 2011

of your team's rules are to be entered on this page. To add each item to your Code, select
the “Create New Item …” button at the bottom of the page. Be sure to designate whether
the item added is a team or individual item. Unlike other online assignments, you will be
able to go back to your Code of Cooperation and edit your items.
Once your team has completed your Code of Cooperation, print out one copy for
submission. Each team member must sign his/her name directly next to his/her name at
the top of the Code. Your signature signifies that you actively participated in the creation
of the Code of Cooperation and that you agree to abide by the rules set forth. Failure to
collect all team members’ signatures will result in a 0 on the assignment.
You will use this online version of your COC to perform your peer and team evaluation
in a few weeks. To ensure that the evaluation goes smoothly, each member of your team
must test his/her own access to your team's Code of Cooperation once your team has
begun entering your team's rules. Should you have access problems (e.g. you are not
accessing your team's Code, your team number is incorrect, or the members of your team
are not correct), contact Chell Nyquist (nyquist@purdue.edu) immediately. All
correspondence with Chell Nyquist must include ENGR 13200 and section number, your
team number, and your Purdue career account login.
Deliverable: Your team must submit one hardcopy printout of your Code of
Cooperation for your entire team. Be sure that your entire Code of Cooperation fits on
your printout. To do this, you may have to use options under the File menu, including
the Page Setup... options or the Printer Properties under Print... Each team member
must sign the Code of Cooperation.

Você também pode gostar