272
Appendix B: Software
q(4,2)=qq(2*b,2);
q(5,1)=q(4,1);
q(5,2)=qq(2*c-1,2);
q(6,1)=p(2,1);
q(6,2)=qq(2*c,2);
end
The driver program to generate Figs. 9.7 and 9.8 is called monofractal_
random.m. After clearing the workspace, it initializes some variables and calls
the function nextiter4_random() with scramble set to zero, which is used
to show the generator in the upper plots in the figures. In the loop over generation
the points are added and reshuffled ten times, where the array p is increased in every
iteration to hold the additional points. After the loop completes, the results are displayed.
% monofractal_random.m
clear all; close all
hold off
scramble=1
% choose 0 or 1
p=[0,0; 1,1];
dp=p(2,:)-p(1,:);
pa=[4/9,2/3];
% control points for the generator
pb=[5/9,1/3];
q0=nextiter4_random(p,pa,pb,0); % unscrambled generator
subplot(4,1,1)
plot(q0(:,1),q0(:,2),’b’)
for generation=1:10
N=size(p,1);
p2=zeros(3*N,2);
mm=1;
for m=1:2:N-1 % only every other
p2(mm:mm+5,:)=nextiter4_random(p(m:m+1,:),pa,pb,scramble);
mm=mm+6;
end
subplot(4,1,2)
plot(p2(:,1),p2(:,2),’b’)
p=p2;
% copy back for next iteration
pause(0.1)
end
jump=7;
% steps for the derivative calculation
subplot(4,1,1)
% the generator
plot(q0(:,1),q0(:,2),’b’)
subplot(4,1,2)
% chart
plot(p2(:,1),p2(:,2),’b’)
subplot(4,1,3)
% derivative of chart, increments
d=p2(jump:end,2)-p2(1:end-jump+1,2);
Appendix B: Software
q(4,2)=qq(2*b,2);
q(5,1)=q(4,1);
q(5,2)=qq(2*c-1,2);
q(6,1)=p(2,1);
q(6,2)=qq(2*c,2);
end
The driver program to generate Figs. 9.7 and 9.8 is called monofractal_
random.m. After clearing the workspace, it initializes some variables and calls
the function nextiter4_random() with scramble set to zero, which is used
to show the generator in the upper plots in the figures. In the loop over generation
the points are added and reshuffled ten times, where the array p is increased in every
iteration to hold the additional points. After the loop completes, the results are displayed.
% monofractal_random.m
clear all; close all
hold off
scramble=1
% choose 0 or 1
p=[0,0; 1,1];
dp=p(2,:)-p(1,:);
pa=[4/9,2/3];
% control points for the generator
pb=[5/9,1/3];
q0=nextiter4_random(p,pa,pb,0); % unscrambled generator
subplot(4,1,1)
plot(q0(:,1),q0(:,2),’b’)
for generation=1:10
N=size(p,1);
p2=zeros(3*N,2);
mm=1;
for m=1:2:N-1 % only every other
p2(mm:mm+5,:)=nextiter4_random(p(m:m+1,:),pa,pb,scramble);
mm=mm+6;
end
subplot(4,1,2)
plot(p2(:,1),p2(:,2),’b’)
p=p2;
% copy back for next iteration
pause(0.1)
end
jump=7;
% steps for the derivative calculation
subplot(4,1,1)
% the generator
plot(q0(:,1),q0(:,2),’b’)
subplot(4,1,2)
% chart
plot(p2(:,1),p2(:,2),’b’)
subplot(4,1,3)
% derivative of chart, increments
d=p2(jump:end,2)-p2(1:end-jump+1,2);
