title: How to extract digits of irrational numbers one by one in Matlab?
body: <p>I'm trying to read digits of irrational numbers such as <code>2^0.5</code> and <code>pi</code> one by one in Matlab.
  I tried using this:</p>
  
  <pre><code>x=pi;
  y=num2str(x)
  out=str2num(y(1))
  </code></pre>
  
  <p>but it only reads just a few digits. Then I tried using vpa function.</p>
  
  <pre><code>x=vpa(pi,100);
  y=num2str(x)
  out=str2num(y(1))
  </code></pre>
  
  <p>but vpa makes x a sym variable which num2str can't read.</p>
  
  <p>Then I tried the method explained in <a href="https://www.mathworks.com/matlabcentral/answers/59178-sum-digits-of-big-numbers#answer_71632" rel="nofollow noreferrer">here</a>, but it only seems to work for rational numbers since</p>
  
  <pre><code>sym(99)^95
  </code></pre>
  
  <p>returns a number which can be read digit by digit using</p>
  
  <pre><code>char(sym(99)^95)-'0'
  </code></pre>
  
  <p>but</p>
  
  <pre><code>sym(2)^0.5
  </code></pre>
  
  <p>just says</p>
  
  <pre><code>ans= 2^(1/2)
  </code></pre>
  
  <p>How can I do the same with irrational numbers to say 10000 digits of precision and store these digits in a (1000,1) array?</p>