MAT LAB SIMPSON
MAT LAB SIMPSON
% Step 2c: Calculate the function values at the odd and even points
oddSum = 0;
evenSum = 0;
for i = 1:n-1
x = a + i * h;
if mod(i, 2) == 1
oddSum = oddSum + myFunction(x);
else
evenSum = evenSum + myFunction(x);
end
end
% Step 2c: Calculate the function values at the odd and even points
oddSum = 0;
evenSum = 0;
for i = 1:n-1
x = a + i * h;
if mod(i, 2) == 1
oddSum = oddSum + myFunction(x);
else
evenSum = evenSum + myFunction(x);
end
end
% Step 2c: Calculate the function values at the odd and even points
oddSum = 0;
evenSum = 0;
for i = 1:n-1
x = a + i * h;
if mod(i, 2) == 1
oddSum = oddSum + myFunction(x);
else
evenSum = evenSum + myFunction(x);
end
end