MATLAB: How to plot this function

plot

I want to plot y for x this equation.
y = 1/2 for x = 0
sin(pi*x/2)/(x*pi) for otherwise
So, I write this code. but It doesnt work. Help me friends.
x = -100:0.1:100;
if x == 0
y = 1/2;
else
y = sin(pi*x/2)/(x*pi);
end
plot(x, y);

Best Answer

x = -100:0.1:100;
y = sin(pi*x/2)./(x*pi);
y(x==0) = 1/2 ;
plot(x, y);