{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw7_solns - Mathematics of Engineering ME17 Spring 2007...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Mathematics of Engineering - ME17 Spring 2007 Homework #7 Solutions Problem 1 [5pts] As for the last assignment, write a Matlab program to plot the five data points as circles, and the functions which pass through these points found using linear and cubic splines. Use the Matlab command interp1 , and turn in Matlab commands and printouts of the figures. Data: ( x 1 ,y 1 ) = (3 . 2 , 22 . 0) ( x 2 ,y 2 ) = (2 . 7 , 17 . 8) ( x 3 ,y 3 ) = (1 . 0 , 14 . 2) ( x 4 ,y 4 ) = (4 . 8 , 38 . 3) ( x 5 ,y 5 ) = (5 . 6 , 51 . 7) Sample program: % ME 17 Homework #7 Solutions %% Problem #2 % Specified Data Points x=[3.2 2.7 1.0 4.8 5.6]; y=[22.0 17.8 14.2 38.3 51.7]; % Dummy variable for plotting xplot=[0:0.1:6]; % Plots plot(x,y,’o’); hold on; plot(xplot,interp1(x,y,xplot)) % linear interp is default plot(xplot,interp1(x,y,xplot,’spline’),’:’); % cubic interpolation legend(’Data’,’Linear Spline’,’Cubic Spline’); xlabel(’x’); ylabel(’y’); Matlab Program Execution Shortcuts: 1. Typing “%% CELLNAME” creates a “cell” in the newest version of MATLAB. You can execute the code in an individual cell using CTRL-ENTER. This allows you to execute sections of code at a time. Note the space between the %’s and the cell name. 2. Open the directory you use. Open an m-file, and save with some suitable name in that directory. Then, to execute the entire m-file, press the F5 key. This automatically saves the whole m-file, and then runs it. 1
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
0 1 2 3 4 5 6 10 20 30 40 50 60 70 x y Data Linear Spline Cubic Spline 3. You can also execute sections of code by highlighting the section and then pressing F9.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern