User Tools

Site Tools


gibson:teaching:fall-2013:math445:hw1

**This is an old revision of the document!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

**Problem 1:** Create the following vectors twice, once using **linspace** and once using the colon operator. 1 2 3 4 5 6 7 8 9 10 2 7 12 **Problem 2:** Use the colon and transpose operators to create a column vector that has values -1 to 1 in steps of 0.2. **Problem 3:** Given a vector //v// of arbitrary length, write an expression that evaluates to the odd-numbered elements of //v//. Test your expression on vectors //v// of both even and odd length. **Problem 4:** Given a vector //v// of arbitrary length, write assignment statements that store the first half of //v// in a vector //v1// and the second half in a vector //v2//. Make sure your assignment statements work for //v// of both even and odd length. Hint: use a rounding function such as **fix**. **Problem 5:** Create a 4 x 2 matrix of all zeros and store it in a variable. Then replace the second row of the matrix with a 3 and a 6. **Problem 6:** Create a 3 x 5 matrix of random real numbers, and then delete the third row. **Problem 7:** What are the values of the following expressions? Explain why. 'c' == 'd' - 1 && 2 < 4 'c' == 'd' - 1 || 2 < 4 xor('c' == 'd' - 1, 2 < 4) 10 > 5 > 2 **Problem 8: The value of $\pi^2/6$ can be approximated by the sum of the series <latex> 1 + \frac{1}{3} + \frac{1}{9} + \frac{1}{27} + \frac{1}{81} + \ldots </latex> Write a one-line Matlab expression that evaluates the sum for the first $n$ terms. Test it for a few values of $n$ and compare to $\pi^2/6$.

gibson/teaching/fall-2013/math445/hw1.1378406168.txt.gz · Last modified: 2013/09/05 11:36 by gibson