
%define the interval and sub-interval
x_start=-2.0*pi
x_end=2.0*pi
x_sub=0.1
N=(x_end-x_start)/x_sub  %number of iteration N+1

%for loop to find discrete x and y values
for i=[1:N+1]
  x(i)=x_start+(i-1)*x_sub;
  y(i)=sin(x(i));
end

plot(x,y,'-*b')
title('Sin Function','Fontsize',15)
xlabel('X value')
ylabel('Y value')
legend('y=sin(x)')