Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

The various roles in a buying decision-making unit.

Answered: 1 week ago

Question

4. What advice would you give to Carol Sullivan-Diaz?

Answered: 1 week ago