Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
filetext = fileread('better_than_fminbnd.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;
xmin=0;
xmax=10*pi;
xopt = better_than_fminbnd(fun,xmin,xmax);
xsubopt = fminbnd(fun,xmin,xmax);
yopt=fun(xopt)
ysubopt=fun(xsubopt)
assert(xopt>=xmin & xopt<=xmax & fun(xopt) < fun(xsubopt))
yopt =
-1.1948
ysubopt =
-1.1948
|
3 | Pass |
fun=@(x)sin(20./x).*sin(20*x)
xmin=1;
xmax=5;
xopt = better_than_fminbnd(fun,xmin,xmax);
xsubopt = fminbnd(fun,xmin,xmax);
yopt=fun(xopt)
ysubopt=fun(xsubopt)
assert(xopt>=xmin & xopt<=xmax & fun(xopt) < fun(xsubopt))
fun =
function_handle with value:
@(x)sin(20./x).*sin(20*x)
yopt =
-0.5881
ysubopt =
-0.5881
|
Find the numeric mean of the prime numbers in a matrix.
6781 Solvers
Return the 3n+1 sequence for n
6167 Solvers
202 Solvers
13 Solvers
Compute a dot product of two vectors x and y
750 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!