function d02la_demo
prompt = {'Initial value of x [the independent variable]',...
'Stepsize for x',...
'Final value for x',...
'Initial value(s) of y [the dependent variable]',...
'Initial value(s) of yp [its derivative]' };
dialogtitle = 'Define initial values for d02la';
num_lines = 1;
default = {'0.0','0.2','10.0','[0.5; 0.0]','[0.0; 1.732050807568877]'};
answer = inputdlg(prompt, dialogtitle, num_lines, default, 'on');
t=str2double(answer{1});
tinc=str2double(answer{2});
tend=str2double(answer{3});
y=str2num(answer{4});
yp=str2num(answer{5});
figure('Name', 'Integrating a non-stiff system of 2nd order ODEs using the NAG Toolbox', ...
'Position', [100, 200, 534, 500],...
'NumberTitle', 'off');
axes = gca;
set(axes, 'FontSize', 13);
xlabel('x');
ylabel('y_{i}', 'Rotation', 0);
xlim([t tend])
ylim([-1.5 1.5]);
title('Using NAG routines d02la, d02lx and d02lz for solving ODEs', 'FontSize', 14);
colors = get(0, 'defaultAxesColorOrder');
text('Interpreter', 'latex',...
'String', '$y_{1}^{\prime\prime}(x) = -y_{1}(x)/[y_{1}^2(x) + y_{2}^2(x)]^{3/2}$',...
'Position', [0.5, 1.35], ...
'Color', [colors(1,1) colors(1,2) colors(1,3)],...
'FontSize', 16);
text('Interpreter', 'latex',...
'String', '$y_{2}^{\prime\prime}(x) = -y_{2}(x)/[y_{1}^2(x) + y_{2}^2(x)]^{3/2}$',...
'Position', [0.5, 1.05],...
'Color', [colors(2,1) colors(2,2) colors(2,3)],...
'FontSize', 16);
hold on;
neqn = nag_int(2);
ydp = zeros(neqn, 1);
rwork = zeros(16+11*neqn, 1);
start = true;
tnext = t+tinc;
x(1) = t;
istep = 1;
z(istep, 1) = y(1);
z(istep, 2) = y(2);
while t < tend
[start, rwork, ifail] = d02lx(0, 1e-4, zeros(neqn,1), zeros(neqn,1), ...
nag_int(0), start, false, false, rwork);
if ifail~=0
disp([' Non-zero ifail after d02lx call ', num2str(ifail)]);
return
end;
[t, y, yp, ydp, rwork, ifail] = d02la('d02la_fcn', t, tnext, ...
y, yp, ydp, rwork);
if ifail ~= 0
disp([' Non-zero ifail after d02la call ', num2str(ifail)]);
return
end;
[ywant, ypwant, ifail] = d02lz(t, y, yp, neqn, tnext, rwork);
if ifail ~= 0
disp([' Non-zero Ifail after d02lz call ', num2str(ifail)]);
return
end;
istep = istep + 1;
x(istep) = tnext;
z(istep, 1) = ywant(1);
z(istep, 2) = ywant(2);
plot(axes, x, z, 'LineWidth', 2);
pause(0.5);
tnext=t+tinc;
end;
clear z x rwork ydp ywant ypwant ;
end