// draws a polynomial clear; //you have to clear variables before startng x=-2:0.001:2; // x is input variable, a row vector x(0)=-2, x(1)=-2+0.001,...,x(n)=2 a0 = 1; a1 = -1; a2 = 2; y= a0 + a1*x + a2*x^2; // calculates function component by component plot(x,y);