display 10 digits of pi in matlab

To display 10 digits of pi in Matlab, you can use the following code:

main.m
format longG
piVal = vpa(pi, 10);
disp(piVal)
46 chars
4 lines

Explanation:

  • format longG sets the display format to show 15 significant digits of the result.
  • vpa() is used to increase the precision of pi up to 10 digits.
  • disp() displays the value of piVal.

Output:

main.m
3.141592654
12 chars
2 lines

gistlibby LogSnag