1) Write a generic function to integrate y(x)dx with the following format function I integrator (x,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1) Write a generic function to integrate y(x)dx with the following format function I integrator (x, y, method) where x is a vector and y is a matrix whose columns y(:,j) are vectors of the same length as x and contain equally spaced data points. The output I is a row vector whose elements are the integrals of each column of y with respect to x. In other words, the jth element of I is I(j) = * y(:,j)dx. method is the technique used, and should either be the string 'trap' for the trapezoidal rule or 'simp' for Simpson's 1/3 rule. If the method argument is missing in the integrator function call, the default method should be set to the trapezoidal rule (Hint: look up how to vary the number of input arguments in a function call). The integrator function should evaluate the number of intervals to integrate and should check that this number is even when Simpson's 1/3 is selected; if that's not the case, the function should stop and print an error message warning the user. The integrator function should contain 2 subfunctions (local functions), one to implement the trapezoidal rule and one to implement Simpson's 1/3 rule. No loop should be used (use vector operations only). Check your subfunctions with simple problems for which you know the answer. 1) Write a generic function to integrate y(x)dx with the following format function I integrator (x, y, method) where x is a vector and y is a matrix whose columns y(:,j) are vectors of the same length as x and contain equally spaced data points. The output I is a row vector whose elements are the integrals of each column of y with respect to x. In other words, the jth element of I is I(j) = * y(:,j)dx. method is the technique used, and should either be the string 'trap' for the trapezoidal rule or 'simp' for Simpson's 1/3 rule. If the method argument is missing in the integrator function call, the default method should be set to the trapezoidal rule (Hint: look up how to vary the number of input arguments in a function call). The integrator function should evaluate the number of intervals to integrate and should check that this number is even when Simpson's 1/3 is selected; if that's not the case, the function should stop and print an error message warning the user. The integrator function should contain 2 subfunctions (local functions), one to implement the trapezoidal rule and one to implement Simpson's 1/3 rule. No loop should be used (use vector operations only). Check your subfunctions with simple problems for which you know the answer.
Expert Answer:
Answer rating: 100% (QA)
Function file function Iintegratorxymethod nlengthx1 hxendx1 I0 formula I... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions

Portray in words what transforms you would have to make to your execution to some degree (a) to accomplish this and remark on the benefits and detriments of this thought.You are approached to compose...

Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...

A ball of mass 0.440 kg moving east( + x direction) with a speed of 3.30m/s collides headon with a 0.220kg ball at rest. If the collision is perfectly elastic, what will be the speed and direction...

Solve the equations in Problems. 1. 3x  8 = 23 2. 2x  8 = 3x + 5 3. 4. + 3 5( 2) 6. 2x +=+ 2 2 3

In this exercise we will consider twoplayer MDPs that correspond to zerosum, turn taking games like those in Chapter 6. Let the players he A and B, and let R (s) be the reward for player A in s....

a. Consider the regression using three explanatory variables, FERTILITY, PUBLICEDUCATION, and LNHEALTH that you did in Exercise 3.3.6. Test whether PUBLICEDUCATION and LNHEALTH are jointly...

Tarp Department Store is located in midtown Platteville. During the past several years, net income has been declining because of suburban shopping centers. At the end of the companys fiscal year on...

Head First Company plans to sell 5, 100 bicycle helmets at $78 each in the coming year Product costs include Direct materials per helmet $32 Direct labor per helmet 5.50 Variable factory overhead per...

We can assume the quiz is posted online and that an answer will be selected for each question. Your program will handle the answers once the quiz has been submitted. The following are required:...

*Harry Consulting is a consulting firm owned and operated by Harry Smith. The endofperiod spreadsheet shown below was prepared for the year ended July 31, 2015: Unadjusted Trial Balance Account...

Tiana Daniles is the sole owner of TSquare Enterprise located in Spanish Town, St. Catherine. The business' trial balance on December 2021 was as follows: Trial Balance at 31 December 2021 Accounts...

NandiphaThabo partnership has built up a small but successful business that has been in operation for over ten years. The business makes a range of ladies' dresses which are sold through boutiques...

In 2022, Nina and Bob are married and reported the following items of income at the end of the tax year: Nina Bob Total Salary $40,000 $0 $40,000 Interest Income $ 1,000 $200 $ 1,200 Total $41,000...

Smith Contractors, Inc. began operations on October 1, 2020. The first three business transactions for the company have already been recorded as reflected in the transactions below and on the...

Q,4 Refer to the circuit in Fig. Let Vc (0) = 45 V. Determine Vc Vy and i, fort2 0. 82 w 122 62 +

Grace is training to be an airplane pilot and must complete five days of flying training in October with at least one day of rest between trainings. How many ways can Grace schedule her flying...

Let x and y be vectors in an inner product space. Show that if x y then the distance between x and y is (x2 + y2)1/2

For n =0, 1,2, show that the Legendre polynomial Pn(x) satisfies the secondorder equation (1  x2)y"  2xy' + n(n + l)y = 0

Show that the matrix will have complex eigen values if is not a multiple Ï. Give a geometric interpretation of this result. cos sin sin cos

Pick any three of the sources of prospects discussed in the chapter and pick a product or service you like. Develop several ideas for how you would use each source to locate leads for the product or...

Why do you think a salesperson might experience call reluctance? How can it be overcome?

List three or four criteria you could use to qualify a lead as a likely prospect. How would you find out if the lead meets these criteria?
Study smarter with the SolutionInn App