At Mark 22: | lrwork and liwork were removed from the interface |
None.
Open in the MATLAB editor: d02qx_example
function d02qx_example fprintf('d02qx example results\n\n'); neqf = int64(2); neqg = int64(2); vectol = true; atol = [1e-06; 1e-06]; rtol = [0.0001; 0.0001]; onestp = false; crit = true; tcrit = 10; hmax = 0; maxstp = int64(0); lrwork = 23*(1+neqf) + 14*neqg; alterg = false; sophst = true; lrwork = 23*(1+neqf) + 14*neqg; rwork = zeros(lrwork,1); liwork = 21 + 4*neqg; iwork = zeros(liwork, 1, 'int64'); % Adams method setup [statefOut, altergOut, rwork, iwork, ifail] = ... d02qw(... 'Start', neqf, vectol, atol, rtol, onestp, crit, tcrit, hmax, ... maxstp, neqg, alterg, sophst, rwork, iwork); % Integrate from t = 0 to 10 t = 0; tout = 10; y = [0; 1]; [t, y, root, rwork, iwork, ifail] = ... d02qf(... @fcn, t, y, tout, @g, neqg, rwork, iwork); % Display solution and integration statistics. fprintf('Solution and root functions at t = %7.4f is:\n',t); [yp, tcurr, hlast, hnext, odlast, odnext, ... nsucc, nfail, tolfac, badcmp, ifail] = ... d02qx(neqf, rwork, iwork); fprintf('\n y :'); fprintf('%10.4f',y); fprintf('\n y'':'); fprintf('%10.4f',yp); fprintf('\n g :'); for i=1:neqg root = g(neqf,t,y,yp,i); fprintf('%10.4f',root); end fprintf('\n\nDiagnostics:\n'); fprintf(' Current value of t = %7.4f\n',tcurr); fprintf(' last time-step = %7.4f\n',hlast); fprintf(' next time-step = %7.4f\n',hnext); fprintf(' last method order used = %7d\n',odlast); fprintf(' next method order used = %7d\n',odnext); fprintf(' successful steps = %7d\n',nsucc); fprintf(' failed steps = %7d\n',nfail); function f = fcn(neqf, x, y) f=zeros(neqf,1); f(1)=y(2); f(2)=-y(1); function result = g(neqf, x, y, yp, k) if (k == 1) result = yp(1)+0.5; else result = y(1)-sqrt(0.5); end
d02qx example results Solution and root functions at t = 0.7854 is: y : 0.7071 0.7071 y': 0.7071 -0.7071 g : 1.2071 0.0000 Diagnostics: Current value of t = 0.9037 last time-step = 0.3620 next time-step = 0.3258 last method order used = 5 next method order used = 5 successful steps = 10 failed steps = 0