EGR 103/Spring 2018/Lab 4

From PrattWiki
Jump to navigation Jump to search

Errors / Additions

None yet!

4.1 Introduction

The main purpose of this lab is to learn how to write functions and to use selective structures. The following is a companion piece to the lab handout itself. The sections in this guide will match those in the handout.

4.2 Resources

See main EGR 103 page for links to these

4.3 Getting Started

Same as it ever was.

4.4 Ungraded

These problems are good ones to look at and to solve but are not a part of the graded work. Given that, you can absolutely consult with classmates about how to get the answers to these ungraded problems.

4.5 Assignment

4.5.1 Chapra 2.10

See the MATLAB:Plotting page for information about the additional pieces of information you can give the plot command to change sizes and colors.

4.5.2 Chapra 2.27

Pretty straightforward. Note that your function will only have three lines of code - the paradigm (the first line at the top of the function that defines the file as a function and names the outputs and inputs) and the two lines that calculate x and y, respectively. The script should to the rest. Putting too much in the function is grounds for losing points. Precious, precious points.

4.5.3 Palm 3.12

See MATLAB:Selective Structures for a reminder of how to use an if tree. Also, think about the order in which you should check for valid arguments. A good first thing to check is whether the user even gave you two arguments to begin with! Click the word "Diary" to see what the diary should be: Diary

Trial  1: Incorrect entry or entries
Trial  2: Incorrect entry or entries
Trial  3: Length: 7.50e-01
Trial  4: Incorrect entry or entries
Trial  5: Incorrect entry or entries
Trial  6: Incorrect entry or entries
Trial  7: Incorrect entry or entries
Trial  8: Impossible Area
Trial  9: Length: 2.00e+00
Trial 10: Incorrect entry or entries
Trial 11: Incorrect entry or entries
Trial 12: Incorrect entry or entries

4.5.4 Chapra 3.14

The main concept here is to use logical masks to create a piecewise function and then use that function to make a plot.

4.5.5 Chapra 3.10

The main concepts here are using logical masks to create piecewise functions, using different sets of points for mathematical analysis versus graphing, and determining and locating extrema.

General Concepts

This section is not in the lab report but rather has some items in it that span multiple problems in the lab.

Functions

See Chapra 3.1.2 and Palm 3.2 through page 123

Selective Structures

See MATLAB:Selective Structures, and note especially that if trees will only run if all the logical expression it is given is true. If you want to run when any of them is true, put the any() command with it. Also see Chapra 3.3.1 and Palm 4.4

Determining and Locating Extrema

See MATLAB:Plotting#Using_Different_Scales and MATLAB:Plotting_Surfaces#Finding_Minima_and_Maxima_in_2-D for some examples. Also see Palm Table 2.1-1.

Logical Masks

See MATLAB:Logical Masks.


Class Document Protection