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...
DNA N-Gram Distribution
Column norms of a matrix
Set some matrix elements to zero
Create a Multiplication table matrix...
What's Your BMI?
Matrix with different incremental runs
Compute sum excluding NaN
Return unique values without sorting
Cody Computer Part 1 - Guess the system font used by uipanel
Cody Computer Part 3 - Detect the graphic card used on Cody Computer
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