To get ten digits of pi in Matlab, you can use the following code:
main.m180 chars4 lines
The format long
command sets the display format to show many decimal places. The num2str
function converts the value of pi to a string with 11 characters (the first two characters are "3." and the remaining nine characters are the ten digits of pi).
The result should be displayed as:
main.m31 chars2 lines
gistlibby LogSnag