This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Ratio of circle's circumference to its diameter


p = pi



p = pi returns the floating-point number nearest to the value of π in IEEE® double-precision. For more information on floating-point numbers, see Floating-Point Numbers.


collapse all

Return the value of π in double precision, which has 15 digits after the decimal point.

format long
p = pi
p = 

Calculate the area of a circle with radius 7.

r = 7;
A = pi*r^2
A = 153.9380

Calculate the surface area and volume of a sphere with radius 5.

r = 5;
SA = 4*pi*r^2
SA = 314.1593
V = 4/3*pi*r^3
V = 523.5988

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a