EGR 103/Spring 2015/Lab 3
Contents
Introduction
The main purpose of this lab is to learn how to write programs almost from scratch 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.
Resources
Getting Started
Same as it ever was. Also note the following typographical errors:
- The line "You will need to copy and paste your Singularity definition from the SingPlot.m file into your new code" on the top of page 6 directly under the equation should instead read: "You will need to copy and paste your Singularity definition from the TestSingularity.m file into your new code"
Assignment
Chapra 2.10
The main concepts here are functions, element-wise calculations, selective structures for validating inputs, and using a combination of point styles with solid lines to represent multiple data sets on the same graph. There is also a diary that is created to document how the code works.
Weather Data Analysis
The main concepts here are loading and parsing data, determining and locating extrema (using commands such as min, max, and find), printing out combinations of literal characters and formatted matrix values, and excising portions of matrices for use later.
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.
Palm 4.19
The main concepts here are validating inputs correctly, generating arrays, running code based on the number of inputs, and using logical masks.
Palm 4.20
The main concepts here are writing piecewise functions correctly and using logical masks.
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.