hwk2_2011

# hwk2_2011 - MSC321 Homework 2 Due February 11 1 Write a...

This preview shows pages 1–2. Sign up to view the full content.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: MSC321 Homework 2 Due February 11 1. Write a program that will print out the value of the function defined below at 200 equally spaced set of points for- 10 ≤ x ≤ 10: f ( x ) = 1 + ( x + 7 . 5)- 8 . 5 ≤ x ≤ - 7 . 5 1- ( x + 7 . 5)- 7 . 5 ≤ x ≤ - 6 . 5 1- ( x + 2 . 5) 2- 3 . 5 ≤ x ≤ - 1 . 50 e- 4( x- 2 . 5) 2- 1 . 25 ≤ x ≤ 6 . 25 1 6 . 5 ≤ x ≤ 8 . 5 otherwise (1) Print the x and f ( x ) in a two-column format, and pipe the output to a file called out.dat . Plot the function using matlab or octave. The commands to do so are \$matlab matlab> x=load(’out.dat’); % read the 2-column file matlab> plot(x(:,1),x(:,2),’k’); % plot x vs f(x) matlab> xlabel(’x’); % label x-axis matlab> ylabel(’f(x)’); % label y-axis matlab> print -dpdf hwk2_1 % save plot to file hwk2_1.pdf. The octave commands are exactly the same as the matlab ones except the printing (last one) which becomes print(’hwk2_1.pdf’,’-dpdf’)print(’hwk2_1....
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

hwk2_2011 - MSC321 Homework 2 Due February 11 1 Write a...

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

View Full Document
Ask a homework question - tutors are online