EGR 103/Spring 2015/Lab 4

From PrattWiki
Revision as of 23:09, 3 February 2015 by DukeEgr93 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The following document is meant as an outline of what is covered in this assignment.

Typographical Errors

None yet!

Specific Problems

Palm Figure 6.1-2, p. 265

The main goals here are to learn how to put italics and math in labels and titles and how to put text on a plot.

Chapra Problem 3.5

The primary goal here is to calculate a series of estimates to the \(\sin(x)\) function using a Maclaurin series.

  • The core of the function will likely be a for loop. There are examples at MATLAB:Iterative_Structures
  • Think carefully about what your scanner variable means and whether you need an external variable. Keep in mind that there are two numbers to keep track of - which term you are on, and what the value of the power of \(x\) and the factorial in the numerator might be. They can be written in terms of each other, or you can use two different variables.
  • Note that your output will have as many entries as the number of terms you asked for - for instance:
>> [X, Y] = SinSeries(pi/2, 5)
X =
   1.5708e+00   9.2483e-01   1.0045e+00   9.9984e-01   1.0000e+00
Y =
  -5.7080e+01   7.5168e+00  -4.5249e-01   1.5690e-02  -3.5426e-04

and

>> [X, Y] = SinSeries(pi/6, 4)
X =
   5.2360e-01   4.9967e-01   5.0000e-01   5.0000e-01
Y =
  -4.7198e+00   6.5164e-02  -4.2652e-04   1.6262e-06

As a result, you need to make sure that your loop is storing each new term in the series in a new entry. On the MATLAB:Iterative_Structures, pay special attention to how the different values are stored in Temperatures.

  • You can actually calculate all the relative errors at once at the very end rather than in the loop if you so choose.

Chapra Problem 4.1

The primary goals here are to re-use an iterative solver with a different iterator and to present the information in a table generated for LaTeX by MATLAB.

  • The code on page 94 of the Chapra book, in Figure 4.2, is incredibly useful and important. You will need to have it memorized eventually, but for now focus on understanding how it does what it does.
  • One difference between your code and the code in the book is that your original sol will be set equal to the first input, called a instead of x in your code. This will happen on the line under the comment % initialization
  • One more difference will be on the line where sol gets updated. Make sure you understand where and how the update is happening in the original code with the original iterator, then re-write it for your iterator.
  • The page on MATLAB:LaTeX_Table_Writer really will be helpful; note that the RunDivAvg.m code already has comments where you need to make changes.
  • The section on MATLAB:LaTeX_Table_Writer#Saving_to_a_File will explain what the fopen and fclose functions, as well FID variable, do.

3D Projections

The primary goal here is to present a graphical representation of a 3-dimensional curve using both isometric and orthographic projections.

General Concepts

Use Piazza to let the instructors know what general concepts you would like more information on for this lab.