Question: MATLAB Numerical Methods Trapezoidal and Simpsons 1/3 Rule: Write a generic function to integrate Integral^x f_x 0 y(x)dx with the following format function I =

MATLAB Numerical Methods Trapezoidal and Simpsons 1/3 Rule:

MATLAB Numerical Methods Trapezoidal and Simpsons 1/3 Rule: Write a generic function

Write a generic function to integrate Integral^x f_x 0 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 j^th element of I is I(j) = Integral^x f_x 0 y(:,j) dx. method is the technique used, and should either be the string 'trap' for the trapezoidal rule or 'sump' 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 f 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 sub functions (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 sub functions with simple problems for which you know the answer. Write a generic function to integrate Integral^x f_x 0 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 j^th element of I is I(j) = Integral^x f_x 0 y(:,j) dx. method is the technique used, and should either be the string 'trap' for the trapezoidal rule or 'sump' 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 f 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 sub functions (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 sub functions with simple problems for which you know the

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!