Difference between revisions of "EGR 103/Fall 2014/Lab 4"
m |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | The following document is meant as an outline of what is covered in this assignment. | |
− | == Palm Figure 6.1- | + | == 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. | 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 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]] | * Information on putting text on a plot is at: [[MATLAB:Plotting#Putting_Text_on_a_Plot]] | ||
+ | * Information for setting the limits and tick locations is at [[MATLAB:Plotting#Setting_Limits_and_Tick_Locations]] | ||
− | == Chapra Problem 3.5 == | + | === Chapra Problem 3.5 === |
− | The primary goal here is to calculate a series of estimates to the <math>\ | + | The primary goal here is to calculate a series of estimates to the <math>\sin(x)</math> function using a [http://mathworld.wolfram.com/MaclaurinSeries.html Maclaurin series]. |
* The core of the function will likely be a <code>for</code> loop. There are examples at [[MATLAB:Iterative_Structures]] | * The core of the function will likely be a <code>for</code> 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 <math>x</math> and the factorial in the numerator might be. They can be written in terms of each other, or you can use two different variables. | * 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 <math>x</math> 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: | * Note that your output will have as many entries as the number of terms you asked for - for instance: | ||
<source lang="matlab"> | <source lang="matlab"> | ||
− | >> [X, Y] = | + | >> [X, Y] = SinSeries(pi/2, 5) |
X = | X = | ||
− | + | 1.5708e+00 9.2483e-01 1.0045e+00 9.9984e-01 1.0000e+00 | |
Y = | Y = | ||
− | + | -5.7080e+01 7.5168e+00 -4.5249e-01 1.5690e-02 -3.5426e-04 | |
</source> | </source> | ||
and | and | ||
<source lang="matlab"> | <source lang="matlab"> | ||
− | >> [X, Y] = | + | >> [X, Y] = SinSeries(pi/6, 4) |
X = | X = | ||
− | + | 5.2360e-01 4.9967e-01 5.0000e-01 5.0000e-01 | |
Y = | Y = | ||
− | + | -4.7198e+00 6.5164e-02 -4.2652e-04 1.6262e-06 | |
</source> | </source> | ||
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 <code>Temperatures</code>. | 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 <code>Temperatures</code>. | ||
* You can actually calculate all the relative errors at once at the very end rather than in the loop if you so choose. | * 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 == | + | === 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 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. | * 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. | ||
Line 37: | Line 43: | ||
* The section on [[MATLAB:LaTeX_Table_Writer#Saving_to_a_File]] will explain what the <code>fopen</code> and <code>fclose</code> functions, as well <code>FID</code> variable, do. | * The section on [[MATLAB:LaTeX_Table_Writer#Saving_to_a_File]] will explain what the <code>fopen</code> and <code>fclose</code> functions, as well <code>FID</code> variable, do. | ||
− | == 3D Projections == | + | === 3D Projections === |
The primary goal here is to present a graphical representation of a 3-dimensional curve using both isometric and orthographic projections. | The primary goal here is to present a graphical representation of a 3-dimensional curve using both isometric and orthographic projections. | ||
* You will need to use the <code>subplot</code> command, which is described in [[MATLAB:Plotting#The_subplot_Function]] | * You will need to use the <code>subplot</code> command, which is described in [[MATLAB:Plotting#The_subplot_Function]] | ||
* You will not have an iterative structure here...at least, you do not need one. | * You will not have an iterative structure here...at least, you do not need one. | ||
+ | |||
+ | == General Concepts == | ||
+ | Use Piazza to let the instructors know what general concepts you would like more information on for this lab. |
Latest revision as of 22:04, 15 September 2014
The following document is meant as an outline of what is covered in this assignment.
Contents
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.
- 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
- Information for setting the limits and tick locations is at MATLAB:Plotting#Setting_Limits_and_Tick_Locations
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, calleda
instead ofx
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
andfclose
functions, as wellFID
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.
- You will need to use the
subplot
command, which is described in MATLAB:Plotting#The_subplot_Function - You will not have an iterative structure here...at least, you do not need one.
General Concepts
Use Piazza to let the instructors know what general concepts you would like more information on for this lab.