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...
Factorize THIS, buddy
Number of 1s in a binary string
Compute a dot product of two vectors x and y
sum of non-primes
Wind outward from the center ...
Fill a zeros matrix
Set the array elements whose value is 13 to 0
Cody Computer Part 4 : Are you a morning Cody player Addicted ?
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