Main Content

pi

Ratio of circle's circumference to its diameter

Syntax

Description

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.

example

Examples

collapse all

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

format long
p = pi
p = 
   3.141592653589793

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™.

Version History

Introduced before R2006a