The test suite is a little soft. I feel the addition of 'for i=log2(2):abs(n^2-n)', which should yield 'for log2' would stymie almost all the solutions provided.
In my opinion, the Cody problems should expand Matlab understanding not cause frustration in search of obscure functions. To this end, I think the tags should include regexp, symvar, cellfun, sprintf, exist, unique, and cell2mat. Learning the usage of these functions is one purpose of Cody.
also operands like +,-,/,*,.*,~,|,& etc. are treated by Matlab as builtin functions, so in my opinion test case 2 answer sholud be ': sqrt sum' and for test case 3 '- ones rand round'
Imho, operators (+,-,&,etc) are a special kind of function in which parameters are arranged in a certain order. The problem does not need to cover them. And again imho, for and if should not even be considered functions, but structures of repetition and control respectively, because they are built-in hardware (and it's how computers work). Moreover they are not mapping values from a set into another as in Math. Finally "functions" that have no output value should be called procedures (such as reset, delete, and disp).
PS: Some operators, these special functions, are also built-in hardware.
Nice...unfortunately, it is not a general solution. For example: if 'x = ones(round(7.7)) - rand + b;', then this code will sniff y = 'b ones rand'.
you found it huh?:) no,it's not a general solution, I built it base on test suite.
Find all elements less than 0 or greater than 10 and replace them with NaN
Set the array elements whose value is 13 to 0
Magic is simple (for beginners)
Calculate the height of an object dropped from the sky
Create an n-by-n null matrix and fill with ones certain positions
Create One Large Eye of size N x N Quickly?
Distance walked 1D
chance in percent for minimum K heads when a good coin is tossed N times?
Find the treasures in MATLAB Central and discover how the community can help you!
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