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.
Roland Mitter (2020). pi read (https://www.mathworks.com/matlabcentral/fileexchange/54105-pi-read), MATLAB Central File Exchange. Retrieved .
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 :)
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.
At the end, if you only want a limited number of digits, then only return the digits of interest.