hw7_solns

hw7_solns - Mathematics of Engineering - ME17 Spring 2007...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 . , 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 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....
View Full Document

This homework help was uploaded on 04/07/2008 for the course ME 17 taught by Professor Milstein during the Spring '07 term at UCSB.

Page1 / 7

hw7_solns - Mathematics of Engineering - ME17 Spring 2007...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online