File Exchange

image thumbnail

pi read

version (480 KB) by Roland Mitter
Just my starting point for having some fun with the digits of pi.


Updated 20 Nov 2015

View License

The function piread reads the digits of pi from a textfile called pi1000000.txt, which contains 1 million digits of pi and saves each digit in an element of a vector. From then on one can play with it ;-)
I didn't publish it as a brilliant piece of code, but just to meet and learn from other people who love to experiment with pi and learn matlab programming as a side effect.

Cite As

Roland Mitter (2020). pi read (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Hi John,
the reason it does not read pi from an .mat file is simply, that I didn't find pi as a .mat file, but only as text files for download. So I used the function to transfer it. And I used that opportunity to learn about matlab programming.
I also thought, that if someone wants to import an even larger txt file for big numbers (maybe pi, e, sqrt(2),...) that he might find it usefull.

The function does only return the digits you like to read from the text file.

However - thanks for checking my function :)

John D'Errico

Um, why not just save the digits as a variable in a .mat file? So rather than a slow read of a text file, you just need to load ONE variable. The difference would be significant, and far easier.

help load

At the end, if you only want a limited number of digits, then only return the digits of interest.

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux