Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a matlab function that uses the composite Simpson?s 1/3 method to find the

ID: 646012 • Letter: W

Question

Write a matlab function that uses the composite Simpson?s 1/3 method to find the definite integral of a function, given the function form and the integration limits. Name the function I= Simpson integral (Fun ,a, b, n), where Fun is the name of a file that contains the desired function (must be passed as a string), a and b are the integration limits, and n the number of points used in the integration (must be an odd number!). Test your code for (at least) the following integrals: The answer for the 1? integral (using 11 points) is 04772 The answer for the 2? integral (also using 11 points) is 2.3522

Explanation / Answer

clc;
clear all;
close all;

f=@(x)x^4; %Change here for different function
a=-3;b=3; %Given limits
n=b-a; %Number of intervals
h=(b-a)/n;
p=0;

for i=a:b
p=p+1;
x(p)=i;
y(p)=i^4; %Change here for different function
end

l=length(x);
x
y

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote