na-lab-simpsons

Version 1.0.1 (1.15 KB) by Akshay
code
1 Download
Updated 15 Nov 2022

View License

clc;
close all;
f=input("Enter function");
a=input("Enter lower limit");
b=input("Enter upper limit");
n=input("Enter no of subintervals");
h=(b-a)/n;
sum=0;
for i=1:n-1
x=a+h*i;
if rem(i,2)==0
sum=sum+2*f(x);
else
sum=sum+4*f(x);
end
end
sum=sum+f(a)+f(b);
sum=sum*(h/3)

Cite As

Akshay (2024). na-lab-simpsons (https://www.mathworks.com/matlabcentral/fileexchange/120428-na-lab-simpsons), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.1

same as composite simpsons

1.0.0