Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

floor

Round toward negative infinity

Syntax

Description

example

Y = floor(X) rounds each element of X to the nearest integer less than or equal to that element.

example

Y = floor(t) rounds each element of the duration array t to the nearest number of seconds less than or equal to that element.

example

Y = floor(t,unit) rounds each element of t to the nearest number of the specified unit of time less than or equal to that element.

Examples

collapse all

Round Matrix Elements Toward Negative Infinity

X = [-1.9  -0.2  3.4;  5.6  7.0  2.4+3.6i];
Y = floor(X)
Y =

  -2.0000 + 0.0000i  -1.0000 + 0.0000i   3.0000 + 0.0000i
   5.0000 + 0.0000i   7.0000 + 0.0000i   2.0000 + 3.0000i

Round Duration Values Toward Negative Infinity

Round each value in a duration array to the nearest number of seconds less than or equal to that value.

t = hours(8) + minutes(29:31) + seconds(1.23);
t.Format = 'hh:mm:ss.SS'
t = 

   08:29:01.23   08:30:01.23   08:31:01.23

Y1 = floor(t)
Y1 = 

   08:29:01.00   08:30:01.00   08:31:01.00

Round each value in t to the nearest number of hours less than or equal to that value.

Y2 = floor(t,'hours')
Y2 = 

   08:00:00.00   08:00:00.00   08:00:00.00

Input Arguments

collapse all

X — Input arrayscalar | vector | matrix | multidimensional array

Input array, specified as a scalar, vector, matrix, or multidimensional array. For complex X, floor treats the real and imaginary parts independently.

floor converts logical and char elements of X into double values.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | logical
Complex Number Support: Yes

t — Input durationduration array

Input duration, specified as a duration array.

unit — Unit of time'seconds' (default) | 'minutes' | 'hours' | 'days' | 'years'

Unit of time, specified as 'seconds', 'minutes', 'hours', 'days', or 'years'. A duration of 1 year is equal to exactly 365.2425 24-hour days.

See Also

| |

Introduced before R2006a

Was this topic helpful?