Comp Trap

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

%test with these parameters

%points = [1 1.5 2 2.5 3]


%equation = x/(1+x)
%h = 0.5
clc
x = input('Enter points of X : ');
a = input('Enter equation :','s');
eq =inline(a);
%equ =input ('Enter the points of z :'); if u put the f(X) we use this function
h = input ('Enter the step size(h): ');
sum = 0 ;
N = length (x);

sum=eq(x(1))+eq(x(N));

for j=2:N-1
sum=sum+(2*eq(x(j)));
end

sum = sum*(h/2);
fprintf("the sum =%f",sum);

You might also like