Name: __________________________
NetID: ________________
Section#: ______
Print out this page and answer the following questions. Hand in this assignment at the beginning of Lab 3. You should use the material found in Lecture 2 of the course notes and/or Matlab by Pratap Chapter 4.2, 4.3 ,5.3 ,6.1. As with all prelabs/labs, if you are not sure of the answer you may go to any EWS lab on campus and check your results by using Matlab, or you can ask anyone of the CS101 staff for help.
The following exercises should help prepare you for the in-lab
activities. Don't forget you can use Matlab Help facilities or the help
command if you need help with the following functions.
______________mean(x)______________________________________
MATLAB defines polynomials by a vector of the coefficients of the terms in descending order. For instance, f = 2x + 3 would be represented as f = [2, 3], where the first element of the vector (2) is the coefficient of the first degree term (2 x1) and the second element of the vector is the coefficient of the zero-th degree term (3 x0). Polynomials that do not have a term for each degree of x MUST have a 0 in the vector for that element (e.g., f = 3x3 + 2x is missing the coefficient of the second degree term and the zero-th term, so the vector representation would be f = [3, 0, 2, 0]).
MATLAB provides several built-in functions that work with
polynomials in this form. For example, to find the roots of a
polynomial, you can simply call the roots
function.
(Remember, the roots of a polynomial are the values of x where
the value of the polynomial is 0.)
To find the roots of the polynomial x2 - 25 , we type the following into the command window,
>> roots([1 0 -25]) -5.00000
5.00000
OR
_________ -5.0000_____5.0000__
written in any
order___no deduction for writing 5.0 rather than 5.0000_________
>> p
= ___________[1 , linspace(0,0,99), -1]__or _[1
, zeros(1,99), -1]____(commas between 1, linspac(...),-1
not necessary)_________
>>
roots(p)
Hint: -1 + x100 = -1 +0*x + 0*x2+0*x3+...+0*x99 + x100 (with 99 0's)
____________polyval([3 0
2 -1], 1:100)_____or______polyval([3,
0, 2, -1], linspace(1,100,100))______________________________