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...
Tic Tac Toe FTW
Back to basics 3 - Temp Directory
Is the Point in a Triangle?
Make a simplified barcode
Make a random, non-repeating vector.
Angle between two vectors
Create a vector whose elements depend on the previous element
Sophie Germain prime
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