Question: You will revise this Matlab code, this Matlab code calculates the area in the trapezoid, you will convert this Matlab code to Simpson. Pay attention

 You will revise this Matlab code, this Matlab code calculates the

You will revise this Matlab code, this Matlab code calculates the area in the trapezoid, you will convert this Matlab code to Simpson. Pay attention to the array indexes in this Matlab code, where the array index is 1, our equation starts from 0. In addition, as n = 2 n = 3 n = 4 like n:... , it should work correctly in all cases. The user should enter a value of n by yourself.

I want Matlab code that works for Simpson h / 3 every situation.

For example, let it be the number of dots is 5. For example, given 5 dots, it will work even if I choose 3 dots, it will work if I give 5 dots and select them all.

area in the trapezoid, you will convert this Matlab code to Simpson.

INPUT endpoints a, b; even positive integer n. OUTPUT approximation Total to 1. Step 1 h = (b a) Step 2 Total = f (a) + f(b) Step 3 For i = 1,...,n - 1 do Steps 4 and 5. Step 4 Set x = a + ih Step 5 If i is even then Total = Total + 2* f(x) else set Total = Total + 4* f(x) h Step 6 Total = -* Total 3 1 $ 2 3- -- 5- 6- 7- 8- 9 1 x(1)x(2)x(3) (4) (5) 1 2 3 4 5 x = [0.1 0.2 0.3 0.4 0.5]; f - (0.718 0.644 0.558 0.55 0.53]; f = y f(1)-y(0.1) b=length(x); $x (f) in eleman sayisini bulur a=1; 8 dizinin ilk indis deeri n-2; * alt blge sayisi total = f(a) +f(b); $ toplam, bataki ve sondaki f deerlerini ekledik & total = f(1) + f (5) h= (x (b)-x(a)); $adim aral (herbir yamuun ykseklii) artim_mik = (b-a); % x lerdeik deiim miktar $ n 4 olduunda 0.1 0.2), (0.2 0.3), (0.3 0.4), 10.4 0.51 $ n=2 olduunda 0.1 0.3), (0.3,0.5) for i=a+artim_mik:artim_mik:b-artim_mik total total + 2*f(i): end total total* (h/2) 11 10- 11 - 12 13 14 - 15 - 16- 17- 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!