- /
- 
        Visualization of random integers 0:9 (or PI)
        on 6 Oct 2021
        
        
 
    - 32
- 218
- 0
- 0
- 254
% Replace the first line of code with these 3 lines to 
% represent the first 10000 digits of pi!  (280 characters)
%     digits(10001);            % symbolic toolbox
%     s=char(vpa(pi));          % symbolic toolbox
%     p=str2num(s(3:end)')';
% Random integers 0:9
p = randi(10,1,10000)-1;
% Theta positions
a=(0:36:324)+(0:.0036:36)';
r=a(sub2ind(size(a),1:1E4,p+1));
% circular distance (used to assign color)
[x,y]=pol2cart(r,1);
[~,~,d]=uniquetol(hypot(diff(x),diff(y)));
c=jet(19);
figure(Color='k')
for i=2:1E4
    polarplot(r(i-1:i),[1,1],Color=[c(d(i-1),:),.1])
    hold on
end
rlim([0,1])
axis off


 

 
            