% Complex bases % computes numbers of the form 0.01110111_b where b is a % complex number b = input('Please enter the complex number base -> '); if b==0 error('Base must be nonzero') end; if abs(b) <=1 disp('Warning: Using a base with absolute value <= 1'); end; if imag(b)==0 disp('Alert: Using a real base'); end; binv = 1/b; d = input('Please enter number of digits -> '); if (d<1) | (fix(d) ~= d) error('Number of digits should be a positive integer'); end; if (d>12) disp('Warning: many digits use lots of memory'); end; % allocate space for zout z = [0]; for k=1:d z = z*binv; z = [z, (z+binv)]; end; if imag(b)~=0 plot(z, '.') else plot(z, z*0, '.') end;