EGR 103/Fall 2014/Lab 4
Jump to navigation
Jump to search
This page is meant to serve as the basis for a self-guided tour of the various parts of Lab 4. It will include relevant links and example for each problem.
Palm Figure 6.1-1, p. 264
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.
- Information on how to labels axes and the title, including using italics: MATLAB:Plotting#General_Plotting_Tips
- Information on putting text on a plot is at: MATLAB:Plotting#Putting_Text_on_a_Plot
Chapra Problem 3.5
The primary goal here is to calculate a series of estimates to the \(\cos(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] = CosSeries(0, 3)
X =
1 1 1
Y =
0 0 0
and
>> [X, Y] = CosSeries(pi/10, 4)
X =
1.0000e+00 9.5065e-01 9.5106e-01 9.5106e-01
Y =
-5.1462e+00 4.2536e-02 -1.4015e-04 2.4717e-07