# channelflow.org

### Site Tools

gibson:teaching:fall-2012:math445:hw1

For each of the following, provide an answer in Matlab-digestable syntax

1. Assign the value 0.00014 to the variable x, using compact scientific notation.

2. Set the variable x to a vector whose components are the even numbers between 14 and 36.

3. Set the variable x to 200 evenly spaced points between 0 and 2.

4. Produce a plot of y = x^2 - 2x + 3 for the x of the previous problem. Label the axes.

5. Plot tan(x) versus x for 200 evenly spaced points between 0 and 1.57 ≈ pi/2, using a logarithmic scale on the y axis.

6. Plot sin(x) and cos(x) for 200 evenly spaced points between -π and π, on the same plot, using red for sin(x) and blue for cos(x). Add a legend that indicates which function is which color.

7. Produce a vector whose components are random integers between 0 and 10, inclusive.

8. Produce a vector whose components are random real numbers between 0 and 10, inclusive.

9. Show how you would solve the following system of equations with Matlab

  x + 2y -  z =   5
3x +  y + 6z =  37
-3x +  y + 2z = -11

10. Write a conditional expression that is true if scalar variables x and y are both nonzero and false otherwise.

11. Set variable A to a 3 x 5 matrix of zeros.

12. Set variable A to a 4 x 7 matrix of random real numbers, using a guassian (normal) distribution.

13. Write a conditional expression that is true if a matrix A is square and false otherwise.

14. Write a conditional expression that is true if either x or y is an integer.

Write a Matlab function that

15. returns 1 (true) if its argument is divisible by 3 and 0 (false) if it's not.

16. takes a vector x as input and returns 1 if the components of x are sorted in ascending order, 0 if not.

17. finds a zero of another function using the bisection search algorithm.

18. computes the product y = Ax of an m x n matrix A and an n x 1 vector x, according the formula

gibson/teaching/fall-2012/math445/hw1.txt · Last modified: 2012/09/26 20:28 by gibson