Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
filetext = fileread('better_than_fminsearch.m');
filetext(find(filetext == '%', 1, 'last') : end) = [];
assert(isempty(strfind(filetext, '>')), 'File handling is forbidden.');
assert(isempty(strfind(filetext, 'eval')), 'Eval forbidden.');
assert(isempty(strfind(filetext, 'regexp')), 'Regexp forbidden.');
assert(isempty(strfind(filetext, '!')), 'Shell commands are forbidden.');
assert(isempty(strfind(filetext, 'mlock')), 'mlock is forbidden.');
assert(isempty(strfind(filetext, 'munlock')), 'munlock is forbidden.');
assert(isempty(strfind(filetext, '@')), 'Anonymous functions are forbidden.');
|
2 | Pass |
fun=@(x)cos(x)-cos(pi*x)/pi;
x0=0;
xopt = better_than_fminsearch(fun,x0)
xsubopt = fminsearch(fun,x0)
yopt=fun(xopt)
ysubopt=fun(xsubopt)
assert(yopt < ysubopt)
xopt =
9.8611
xsubopt =
0
yopt =
-1.1948
ysubopt =
0.6817
|
3 | Pass |
fun=@(x)sin(20./x).*sin(20*x)
x0=1;
xopt = better_than_fminsearch(fun,x0)
xsubopt = fminsearch(fun,x0)
yopt=fun(xopt)
ysubopt=fun(xsubopt)
assert(yopt < ysubopt)
fun =
function_handle with value:
@(x)sin(20./x).*sin(20*x)
xopt =
11.2313
xsubopt =
1.0803
yopt =
-0.9780
ysubopt =
-0.1239
|
6064 Solvers
Given two strings, find the maximum overlap
461 Solvers
Project Euler: Problem 9, Pythagorean numbers
282 Solvers
30 Solvers
22 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!