Print Level = 1is an example of a string used to set an optional parameter. For each option the string contains one or more of the following items:
– | a mandatory keyword; |
– | a phrase that qualifies the keyword; |
– | a number that specifies an integer or double value. Such numbers may be up to contiguous characters in Fortran's I, F, E or D formats, terminated by a space if this is not the last item on the line. |
[lwsav, iwsav, rwsav, inform] = e04dk('Nolist', lwsav, iwsav, rwsav);suppresses printing of this and subsequent options. Printing will automatically be turned on again after a call to nag_opt_uncon_conjgrd_comp (e04dg) and may be turned on again at any time using the keyword List.
None.
Open in the MATLAB editor: e04dk_example
function e04dk_example fprintf('e04dk example results\n\n'); % Initialize minimizer and set some options [cwsav,lwsav,iwsav,rwsav,ifail] = e04wb('e04dg'); [lwsav, iwsav, rwsav, inform] = e04dk(... 'Iteration Limit = 25', lwsav, iwsav, rwsav); [lwsav, iwsav, rwsav, inform] = e04dk(... 'Print Level = 0', lwsav, iwsav, rwsav); [lwsav, iwsav, rwsav, inform] = e04dk(... 'Nolist', lwsav, iwsav, rwsav); [lwsav, iwsav, rwsav, inform] = e04dk(... 'Verify Level = 1', lwsav, iwsav, rwsav); [lwsav, iwsav, rwsav, inform] = e04dk(... 'Maximum Step length = 100', lwsav, iwsav, rwsav); % Initial guess. x = [-1; 1]; % Minimize [iter, objf, objgrd, x, user, lwsav, iwsav, rwsav, ifail] = ... e04dg(... @objfun, x, lwsav, iwsav, rwsav); fprintf('Number of iterations = %10d\n',iter); fprintf('Value of objective function = %10.3e\n',objf); fprintf('Value of df/dx = %10.3e\n',objgrd(1)); fprintf('Value of df/dy = %10.3e\n',objgrd(2)); fprintf('Location of minimum = (%7.3f,%7.3f)\n',x); function [mode, objf, objgrd, user] = objfun(mode, n, x, nstate, user) a = x(1); b = x(2); expa = exp(a); objf = expa*((2*a+b)^2 + (b+1)^2); if (mode == 2) objgrd(1) = 4*expa*(2*a+b) + objf; objgrd(2) = 2*expa*(2*a+2*b+1.0); else objgrd = zeros(2,1); end
e04dk example results Number of iterations = 10 Value of objective function = 5.293e-14 Value of df/dx = 9.125e-07 Value of df/dy = 8.316e-07 Location of minimum = ( 0.500, -1.000)