At Mark 22: | lrwork was removed from the interface |
Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.
– | nag_ode_ivp_2nd_rkn (d02la) has not been called; |
– | one or both of the arguments neq and lrwork does not match the corresponding argument supplied to the setup function nag_ode_ivp_2nd_rkn_setup (d02lx); |
– | no integration steps have been taken since the last call to nag_ode_ivp_2nd_rkn_setup (d02lx) with ; |
– | or . |
Open in the MATLAB editor: d02lz_example
function d02lz_example fprintf('d02lz example results\n\n'); % Variables and arrays for integration setup neq = 2; h = 0; tol = 1e-4; thres = zeros(neq, 1); thresp = zeros(neq, 1); maxstp = int64(1000); start = true; onestp = true; high = false; rwork = zeros(16+20*neq,1); % Integration setup [startOut, rwork, ifail] = d02lx... (h, tol, thres, thresp, maxstp, start, onestp, high, rwork); % Integration variables t = 0; tend = 20; y = [0.5; 0]; yp = [0; sqrt(3)]; ydp = zeros(neq, 1); tnext = 2; nwant = int64(2); fprintf('\n T Y(1) Y(2)\n'); fprintf('%4.1f %10.5f %10.5f\n', t, y(1), y(2)); % Integrate by steps and interpolate onto selected values while (t < tend && ifail == 0) [t, y, yp, ydp, rwork, ifail] = d02la(@fcn, t, tend, y, yp, ydp, rwork); while (tnext <= t && ifail == 0) [ywant, ypwant, ifail] = d02lz(t, y, yp, nwant, tnext, rwork); fprintf('%4.1f %10.5f %10.5f\n', tnext, ywant(1:2)); tnext = tnext + 2; end end if (ifail == 0) [hnext, hused, hstart, nsucc, nfail, natt, thres, thresp, ifail] = ... d02ly(nwant, rwork); fprintf('\n Number of successful steps = %d\n', nsucc); fprintf(' Number of failed steps = %d\n', nfail); end function ydp = fcn(neq, t, y) % Evaluate second derivatives. r = sqrt(y(1)^2+y(2)^2)^3; ydp(1) = -y(1)/r; ydp(2) = -y(2)/r;
d02lz example results T Y(1) Y(2) 0.0 0.50000 0.00000 2.0 -1.20573 0.61357 4.0 -1.33476 -0.47685 6.0 0.35748 -0.44558 8.0 -1.03762 0.73022 10.0 -1.42617 -0.32658 12.0 0.05515 -0.72032 14.0 -0.82880 0.81788 16.0 -1.48103 -0.16788 18.0 -0.26719 -0.84223 20.0 -0.57803 0.86339 Number of successful steps = 108 Number of failed steps = 16