You are essentially where you want to be. It helps to assign the output of your function to a different variable. (I use ‘v’ here.)
I am not certain what problems you are having with the plot call. There are two ways to plot it:
y = @(w,x,E,I,l)((w*(x.^2))/(24*E*I).*((x.^2)+6*(l^2)-4*x*l));
v = y(2,0:0.001:2,70,0.00012,2);
figure
plot(v) % Plot As A Function Of The Vector Indices
grid
figure
plot((0:0.001:2), v) % Plot As A Function Of The Vector
grid