User Tools

Site Tools


A PCRE internal error occured. This might be caused by a faulty plugin
gibson:teaching:fall-2013:math445:hw4

===== Math 445 HW4 ===== This homework is meant as review for the second-chance exam to be held Nov 26. It is due Thursday Nov 14th in lecture. Review topics * **fprintf:** formatted printing function * **plotting:** ''plot, semilogy, semilogx, loglog, contour, mesh'' * **loops:** ''for'' and ''while'' * **anonymous functions:** defining and using * **solving equations:** with ''fzero'' or ''newtonsearch'' \\ **Problem 1:** Write a Matlab function named ''farenheit2celsius'' that converts degrees Farenheit to degrees Celsius, according to the formula $C = 5/9 (F-32)$. Write the function in a file ''farenheit2celsius.m''. \\ **Problem 2:** Write a for-loop that prints a Farenheit to Celsius conversion table for values of //F// between -10 and 120 degrees, in increments of 10 degrees //F//. The output should look something like this: <code> 0 F == -17.8 C 10 F == -12.2 C </code> etc. Hint: use ''fprintf'' with a formatting codes ''%3d'' and ''%6.1f'' to get the numbers to line up nicely. That's three spaces for the integer //F// numbers, and six spaces for the floating-point //C// numbers, with 1 digit after the decimal point. \\ **Problem 3:** Make a plot of C versus F over the range %%-50 <= F <= 212%%. Put symbols on the line where water freezes and boils: a circle for freezing and a square for boiling. Label the axes and give the graph an appropriate title. \\ **Problem 4:** Use Matlab's anonymous function facility to define a ''farenheit2celsius'' function at the Matlab prompt, instead of writing it in a file as in problem 1. \\ **Problem 5:** Use matlab's ''fsolve'' function or your ''newtonsearch'' function and the ''farenheit2celsius'' function from problem 4 to find the temperature that has the same numerical value in //F// and //C//. Verify your answer by solving the equation with algebra. \\ **Problem 6:** Verify your answer from problem 5 by evaluating your ''farenheit2celsius'' function at the value found as an answer to problem 5. \\ **Problem 7:** Write a script that produces a multiplication table like this <code> 1 2 3 4 2 4 6 8 3 6 9 12 </code> only for the numbers 1 through 10 in both the rows and columns. Using two nested for-loops and the ''fprintf'' function with a formatting code like in problem 2 to get uniform spacing. \\ **Problem 8:** Find a solution to the system of equations <latex> \begin{align*} x_1^2 - x_2 &= -2 \\ x_1 \sin(x_2) &= 4 \end{align*} </latex> using Matlab's ''fsolve'' function or your ''newtonsearch''. \\ **Problem 9:** Deduce the functional relationship ''y(x)'' for the data in this plot. {{:gibson:teaching:fall-2013:math445:prob9.png?nolink&300|}} \\ **Problem 10:** Assume you have a file ''data.asc'' containing the data for the above graph, with the //x// values in the first column and the //y// values in the second column. Write the Matlab code that would load the data and produce the above plot.

gibson/teaching/fall-2013/math445/hw4.txt · Last modified: 2013/11/14 09:43 by gibson