%integrates a function

N=20;
D=1;%this is theb interval
delta=D/(N-1);

x=[0:delta:D];
x=x';


f=x.^2;
f=sqrt(x);


figure(100)

plot(x,f,'b','Linewidth',2)
xlabel('$x$','Interpreter','latex')
ylabel('$f=x^2$','Interpreter','latex')
set(gca,'Fontsize',24)
grid on

G=ones(1,N);
G(1)=1/2;G(N)=1/2;
G=delta*G;

I=G*f;

[I,2/3]

