MATLAB Warnings under fmincon -
i'm minimizing function fmincon routine.
this function uses integral command several times. however, of integrals turns out inf or nan , don't want matlab show warning when happens (the function finite).
i've tried using command warning('off','matlab:integral:nonfinitevalue') don't seem working when running optimization.
it you're suppressing wrong message. inspect values of
[a,b] = lastwarn inside output function (opts = optimset('outputfcn', @myoutfcn);) make 100% sure you're killing correct warning message.
but have encountered annoying behavior before -- can't seem suppress warnings in matlab's own functions. those, have resort ugly , fragile hacks.
you try
warning off ... warning on which suppresses all warnings code contained in '...' section.
you use undocumented feature: temporarily promote warning error:
ws = warning('error', 'matlab:integral:nonfinitevalue'); ... warning(ws); and wrap in try....catch. chances interrupt integral , fmincon prematurely , have wrap rescue mechanism, gets real complicated , real ugly real fast, that's used last resort...
...so in all, it's easiest live warnings.
Comments
Post a Comment