EGR 103/Spring 2017/Lab 3

From PrattWiki
Revision as of 01:56, 1 February 2017 by DukeEgr93 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Typographical errors

None identified yet!

3.1 Introduction

The main purpose of this lab is to learn how to write programs and how to write functions and scripts that work together. The following is a companion piece to the lab handout itself. The sections in this guide will match those in the handout.

3.2 Resources

See main EGR 103 page for links to these

3.3 Getting Started

Same as it ever was.

3.4 Assignment

3.4.1 Chapra 2.6

For the error checking, for check the number of arguments then - if you have the correct number - whether any have an incorrect number of entries. For the plot, note that the units of time will be seconds (s) and the units of charge will be coulombs (C).

3.4.2 Chapra 2.22

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.

3.4.3 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.

3.4.4 Palm 4.44

The main concepts here are using the switch-case-otherwise structure when your code is to run certain lines of codes based on strings, using different point styles if you have five or more lines to graph in black and white, put using scripts and functions together.

3.4.5 Leap Years

The main concepts here are validating inputs correctly, generating arrays, running code based on the number of inputs, and using logical masks. The code for determining the leap year output can be done in one line! You may want to investigate the mod command.

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