r = roots(p) returns the roots of the polynomial represented by p as a column vector. Input p is a vector containing n+1 polynomial coefficients, starting with the coefficient of xn. It does not accept a vector of values of your function and find the zeros of the function that takes those values. In other words, since x has 201 elements so does y and so r is the roots of a 200th degree polynomial not the 5th degree polynomial you evaluated to compute y. Zero crossings in a vector is better done by comparing the sign of the elements in that vector, or perhaps interpolation and fzero.
On the other hand, y1 does not represent the polynomial you evaluated to compute y. You're missing the constant term, which has to be present in the coefficient vector even if it's 0. But it's closer.
Best Answer