function rollcont = g05fa_demo(rolling)
global mypause;
mypause = 0.01;
if nargin < 1
rolling = 0;
end
global quit;
quit = 0;
rollcont = 1;
n = nag_int(10000);
a = 0;
b = 1;
igen = nag_int(1);
iseed = [nag_int(10); nag_int(7); nag_int(19); nag_int(58)];
[x, iseedOut, ifail] = g05lg(a, b, n, igen, iseed);
[y, iseed, ifail] = g05lg(a, b, n, igen, iseedOut);
idim = nag_int(2);
[iref, ifail] = g05yc(idim);
[quasi, irefOut, ifail] = g05yd(n, iref);
scrsz = get(0,'ScreenSize');
if rolling
figure('Name', 'NAG random numbers', ...
'Position', [0 -35 scrsz(3)*1.0 scrsz(4)*1.0], ...
'NumberTitle', 'off');
else
figure('Name', 'NAG random numbers', ...
'Position', [scrsz(1)+100 scrsz(2)+50 scrsz(3)*0.8 scrsz(4)*0.8], ...
'NumberTitle', 'off');
end
if rolling ~= 1
procbutton = uicontrol('Position', [10 45 130 30], ...
'String', 'Start', 'Callback', @button_handler);
end
closebutton = uicontrol('Position', [10 10 130 30], 'String', 'Quit', ...
'Callback', @button_handler);
if rolling ~= 1
set(closebutton, 'Enable', 'Off');
end
uicontrol('Style', 'popup', 'String', 'Slow|Medium|Fast|Whoa', ...
'Position', [10 70 110 30], 'TooltipString', ...
'Chooses the speed of animation', ...
'Value', 3, 'Callback', @animspeed);
subplot(2,1,1)
hold on;
title ('Pseudo-random numbers', 'FontSize', 14);
subplot(2,1,2)
hold on;
title ('Quasi-random numbers', 'FontSize', 14);
subplot(2,1,1)
cla;
subplot(2,1,2)
cla;
if rolling ~= 1
set(closebutton, 'Enable', 'On');
uiwait(gcf);
end
if mypause == 0.0
nat = n;
else
nat = 10;
end
savemovie = 0;
framenumber = 0;
if savemovie == 1
FF = getframe(gcf);
[FX,Map] = frame2im(FF);
filename = sprintf('frame%d.png', framenumber);
imwrite(FX,filename,'png');
framenumber = framenumber + 1;
end
cont = 1;
while (cont)
for ii = 1 : nat : n
if mypause == 0.0
nn = n - ii + 1;
mc = 'blue';
else
nn = nat;
mc = 'red';
end
subplot(2,1,1)
scatter(x(ii:ii+nn-1), y(ii:ii+nn-1), 10, 'filled', 'MarkerFaceColor', mc);
subplot(2,1,2)
scatter(quasi(ii:ii+nn-1,1), quasi(ii:ii+nn-1,2), 10, 'filled', 'MarkerFaceColor', mc);
if ii > 1 && mypause ~= 0.0
subplot(2,1,1)
scatter(x(ii-nn:ii-1), y(ii-nn:ii-1), 10, 'filled', 'MarkerFaceColor', 'blue');
subplot(2,1,2)
scatter(quasi(ii-nn:ii-1,1), quasi(ii-nn:ii-1,2), 10, 'filled', 'MarkerFaceColor', 'blue');
end
if quit == 1
rollcont = 0;
close all;
return;
end
if mypause == 0.0
break;
end
if savemovie == 1
FF = getframe(gcf);
[FX,Map] = frame2im(FF);
filename = sprintf('frame%d.png', framenumber);
imwrite(FX,filename,'png');
framenumber = framenumber + 1;
end
pause(mypause);
end
if rolling == 1
cont = 0;
else
set(procbutton, 'String', 'Restart');
uiwait;
subplot(2,1,1)
cla;
subplot(2,1,2)
cla;
pause(mypause);
end
if mypause ~= 0.0
nat = 10;
end
end
end
function button_handler(hObject, eventData)
global quit;
label = get(hObject, 'String');
if strcmp(label, 'Close') || strcmp(label, 'Quit')
close;
quit = 1;
elseif strcmp(label, 'Pause')
set(hObject, 'String', 'Resume');
uiwait;
elseif strcmp(label, 'Start') || strcmp(label, 'Resume') || strcmp(label, 'Restart')
set(hObject, 'String', 'Pause');
uiresume;
elseif strcmp(label, 'Next')
uiresume;
end
end
function animspeed(hObject, eventData)
global mypause;
val = get(hObject, 'Value');
if val == 1
mypause = 0.75;
elseif val == 2
mypause = 0.125;
elseif val == 3
mypause = 0.001;
else
mypause = 0.0;
end
end
ans =
0