Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function Handles 1. Write a two-argument function apply, whose first argument is a function handle and whose second argument is an array of values. Use

image text in transcribed
image text in transcribed
Function Handles 1. Write a two-argument function apply, whose first argument is a function handle and whose second argument is an array of values. Use a for loop to evaluate the function handle for each value of the input array and store the results in an output array. For example: apply(n) sun(1:n), [1:10]) would evaluate to [1 3 6 le 21 28 36 45 55] Filename: apply. and so that 2. Write a function parabola whose three arguments (A, B, and c) are the coefficients of a quadratic function f(x) = Ax? + Br + C. The result of this function must be a function handle for the corresponding quadratic function. Use dot operators like the resulting function is vectorized' meaning it can work on a whole array at once. Filename parabola. Test Functions 3. Write a suite of tests for the wywean function 1. testman_allsae.. input an array of all the same value, like fift) expect 2. test wymian_bylland.: input (100 96 4 20 36 2): calculate the expected result by hand to construct the test. 3. test wyman_sinusito: input an array of integers, t-N:11N) expect a 4. testymean_one Tone: input an array of integers, (1:1:N), expect (N+1)/2 5. test_synean_uniform.. input many uniformly distributed values between 0 and 1 (perhaps use linspace), expect a.s. 6. test anfractions. :input-.-., , .expect 4.1 Exercise 3.5 Write tests for the midpoint function 4. LL Exercise 3.5: Write tests for the midpoint function Modify the file test trapezoidal.m such that the three tests are applied to the function midpoint implementing the midpoint method for integration. Filenames: .. test_midpoint_one_exact_result.m test_midpoint_linear.. test_midpoint_conv_raten test_midpoint_YouPickSomeGoodName.m Modifications and additions: Three tests are expected, analogous to the tests of trapezoidal from the text. Place each test in a separate file, rather than all in a single file. . Please write a fourth test of whether midpoint gives the expected result (within tolerance, and for a large number of intervals) of an easily calculable integral such as sc r'dx = or "sin(x)dx = 2

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions