The aim is to find all the zeros of a function within an interval.
output = find_zeros(@sin,0,2*pi) will return :
output = [0.0000 3.1416 6.2832]
since the sinus function between [0 2pi] is zero for [0 pi 2pi]
I think test case 2 might be incorrect.
I disagree slightly with the expected solution to test 2.
Test 2 cos between [0 2pi]
[-pi/2 pi/2 3*pi/2]
I do not believe that -pi/2 is in the interval [0 2*pi].
If -pi/2 is desired then the answer to sin [0 2*pi] should be [-2*pi -pi 0 pi 2*pi]
Correction of assert function.
One of the ")" is in the wrong place.
assert(all(abs(find_zeros(@sin,0,2*pi) -[0 pi 2*pi]<1e-9))
Yeah, the test set is wrong...
Find all elements less than 0 or greater than 10 and replace them with NaN
Find the alphabetic word product
Find number of days
Cody Computer Part 4 : Are you a morning Cody player Addicted ?
Convert a numerical matrix into a cell array of strings
Cody Computer Part 2 - Get the license number of Cody Computer
Get the elements of diagonal and antidiagonal for any m-by-n matrix
Set some matrix elements to zero
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office