DOC PREVIEW
CR MATH 45 - Exam #4 Linear Algebra Matlab Component

This preview shows page 1-2-3-4 out of 11 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Solutions to ExercisesCollege of the RedwoodsMathematics DepartmentMath 45—Linear AlgebraExam #4Linear AlgebraMatlab ComponentDavid ArnoldCopyrightc 2000 [email protected] Revision Date: December 16, 2000 Version 1.002Essay QuestionsDirections: You must complete this exam in one sitting in Room 116 of the physical sciences building. Youmay take the exam Monday, Tuesday, or Wednesday, December 4–6. You must follow directions exactly toreceive credit for your solutions. Please do not share any questions or results on this examination with fellowstudents until all have taken the examination. Finally, this examination is closed book, closed notes. Youmay not view any activities online to aid in the completion of this examination. You are free, however, touse any of Matlab’s help files. Good luck!Exercise 1. Consider the following set of data.ty0 1595148910209915193620898(a) Use the technique of least squares to fit a parabola having form y = at2+ bt + c to the data set. Showall preparatory work on college ruled paper. Your work should include the following:•A system of equations generated by substituting each data point from the table into y = at2+bt+c.•A matrix equation for the system.•The solutions for a, b,andc and the equation y = at2+ bt + c.•Any other intermediate results you deem important.(b) Plot the data set and the parabola of best fit on the same plot. Use the xlabel, ylabel,andtitlecommands to provide appropriate axes labels and a title containing the equation of the parabola.(c) Prepare an M-file containing all commands used to generate solutions in each part of this exercise. Saveyour M-file on your H drive and include a printout of your M-file with your examination. Place your loginname and the filename of your M-file on the printout. I will be running your M-files from my office andgrading them on performance. Note: Recall that Matlab’s figure command opens a new figure windowfor plotting. Also, placing close all at the beginning of your file will close all open figure windows.Exercise 2. Consider the following set of data.xy2 582316114320655618687607129408181599243361031615(a) Use Matlab to plot the data. Use the appropriate plots to determine whether it is better to fit the datato an exponential modely = aebx,or a power function having formy = axb.Justify your choice of model.3(b) Use a linear algebra least squares technique to fit your choice of model to the data. Provide two plots.The first plot should show the linear relationship found in the data set. The second plot should showa plot of the original data set and the plot of the model found that fits the data. Again, show allintermediate work, as in Exercise 1, on college ruled paper.(c) Prepare an M-file that performs all of the necessary work, including the generation of all plots. YourM-file should use the xlabel, ylabel,andtitle commands to provide appropriate axes labels and atitle containing the equation of the current plot. Save the file on your H drive. Obtain a printout ofyour M-file and include it with your examination papers. Place your login name and the filename of yourM-file on the printout. I will be running these M-files from my office to grade their performance. Note:Recall that Matlab’s figure command opens a new figure window for plotting. Also, placing close allat the beginning of your file will close all open figure windows.Solutions to Exercises 4Solutions to ExercisesExercise 1(a) First, substitute each data point in the equation y = at2+ bt + c.159 = a(0)2+ b(0) + c1489 = a(5)2+ b(5) + c2099 = a(10)2+ b(10) + c1936 = a(15)2+ b(15) + c898 = a(20)2+ b(20) + cThis system of equations has matrix form 0201525110210 115215 120220 1abc=159148920991936898.Note that this system has the form Ax = y, whereA =0201525110210 115215 120220 1, x =abc, and y =159148920991936898.Enter matrix the t-data in Matlab.>> tt=05101520Now enter matrix A.>> A=[t.^2,t,ones(size(t))]A=0012551100 10 1225 15 1400 20 1Enter the vector y.>> y=[159;1489;2099;1936;898]y=159148920991936898Solutions to Exercises 5Set up the normal equations by multiplying both sides of Ax = y by AT.ATAˆx = ATyIn Matlab, set up the augmented matrix.M=[A’*A,A’*y]M=221250 12500 750 104192512500 750 50 75435750 50 5 6581Reduce.>> R=rref(M)R=1.0000 0 0 -15.74000 1.0000 0 353.30000 0 1.0000 144.2000Therefore,>> xhat=R(:,4)xhat =-15.7400353.3000144.2000and a = −15.74, b = 353.3, and c = 144.2. The best fit polynomial isy = −15.74t2+ 353.3t + 144.2.Exercise 1(b) Prepare the polynomial data.>> tt=linspace(-1,21)>> yy=-15.74*tt.^2+353.3*tt+144.2Plot the data and the best fit polynomial.plot(t,y,’o’,tt,yy)Label the axes and provide a title.>> xlabel(’t-axis’)>> ylabel(’y-axis’)>> title(’The best fit polynomial y=-15.74t^2+353.3t+144.2’)These commands produce the image in Figure 1. Exercise 1(c) Here is the M-file I used to prepare my solution. Note that I have carefully commented mycode, always a good practice for programmers. At the end of the file, note that I have sized the graphic,then saved it in encapsulated postscript, color, level 2 postscript, for inclusion in my LATEX document.%close all existing figure windowsclose all%Enter dataSolutions to Exercises 6−5 0 5 10 15 20 25−50005001000150020002500tiy−axisThe best fit polynomial y=−15.74t2+353.3t+144.2Figure 1: The best fit polynomial.t=(0:5:20).’y=[159;1489;2099;1936;898]%build matrix AA=[t.^2,t,ones(size(t))]%Craft normal equationsM=[A’*A,A’*y]%reduce, then strip xhat from last columnR=rref(M)xhat=R(:,4)%build best fit polynomialtt=linspace(-1,21)yy=-15.74*tt.^2+353.3*tt+144.2%plot data and polynomialplot(t,y,’o’,tt,yy)%labels and titlexlabel(’t-axis’)ylabel(’y-axis’)title(’The best fit polynomial y=-15.74t^2+353.3t+144.2’)%change the paper size (4 inches by 3 inches)%of the image prior to savingset(gcf,’PaperPosition’,[0,0,4,3])%saving the image for inclusion in TeX documentprint -depsc2 matlabexam1.epsExercise 2(a) First, enter the data in Matlab.>> x=(2:10).’Solutions to Exercises 72 4 6 8 1067891011log(y)A plot of log(y) versus xFigure 2: The plot of ln y versus x is not linear.>> y=[582;1611;3206;5618;8760;12940;18159;24336;31615]Ify = aebx,thenln y =lnaebx,ln y =lna +lnebx,ln y


View Full Document

CR MATH 45 - Exam #4 Linear Algebra Matlab Component

Documents in this Course
Load more
Download Exam #4 Linear Algebra Matlab Component
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Exam #4 Linear Algebra Matlab Component and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Exam #4 Linear Algebra Matlab Component 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?