Integration using the built-in 'int' command

dx = 0.1; % dx step size. x = 0:dx:20; % array of x values [0:20] y = x.^2; % y is a function of x % Integrate . format long % print more digits. I1 = trapz(x,y) % trapz. I2 = dx*trapz(y) % trapz again. The integrals, I1 and I2 should have printed in the Matlab window. To obtain precise results it is important that be a small number. Making . dx ................
................