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);
h = input ('Enter the step size(h): ');

N = length (x);
sum=0;
for j=1:N
if mod(j,2)==0
sum=sum+eq(x(j));
end
end
sum = sum*(2*h);
fprintf("the sum =%.3f",sum);

You might also like