Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Needing Matlab code for this. I don't even know how to get started please help Thanks. 1) write a generic function to integrate | (x)dr

image text in transcribed

Needing Matlab code for this. I don't even know how to get started please help Thanks.

1) write a generic function to integrate | (x)dr with the following format function 1 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()- [y(.j)dr 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. The integrator function should evaluate the number of intervals to integrate and should check that this number is even when Simpson's 1/3 rule 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. Hint: You may want to start writing this function for the easier special case of integrating a vector y and obtaining a scalar output I, and then, after checking your results, modifying your code to handle the general case of a matrix y yielding a vector . 1) write a generic function to integrate | (x)dr with the following format function 1 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()- [y(.j)dr 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. The integrator function should evaluate the number of intervals to integrate and should check that this number is even when Simpson's 1/3 rule 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. Hint: You may want to start writing this function for the easier special case of integrating a vector y and obtaining a scalar output I, and then, after checking your results, modifying your code to handle the general case of a matrix y yielding a vector

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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

8. Name the three catecholamine neurotransmitters.

Answered: 1 week ago