MATLAB: Plot shows empty display

MATLAB

I am using the following code to make a plot. However, I do not see the line being plotted. Why is this?
 
x = 0:100:1;
y = x.^2;
plot(x,y);

Best Answer

In this code, the first line has the effect of creating a variable "x", with just the scalar value 0. 
This is because the second value represents the step size in the linearly spaced vector that we wish to create, and not the number of points. 
Because of this, both "x", and "y" end up being scalar inputs to the "plot" function. 
To rectify this, replace the first line with the following :
x = 0:1/100:1;
y = x.^2;
plot(x,y);