floor - Round toward negative infinity - MATLAB (original) (raw)

Main Content

Round toward negative infinity

Syntax

Description

Y = floor([X](#bug%5F5mn-1-X)) rounds each element of X to the nearest integer less than or equal to that element.

example

Y = floor([t](#bug%5F5mn-1-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](#bug%5F5mn-1-t),[unit](#bug%5F5mn-1-unit)) rounds each element of t to the nearest number of the specified unit of time less than or equal to that element.

example

Examples

collapse all

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

Y = 2×3 complex

-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 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 = 1×3 duration 08:29:01.23 08:30:01.23 08:31:01.23

Y1 = 1×3 duration 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 = 1×3 duration 08:00:00.00 08:00:00.00 08:00:00.00

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, multidimensional array, table, or timetable. 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 | table | timetable
Complex Number Support: Yes

Input duration, specified as a duration array.

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.

Extended Capabilities

expand all

Thefloor function fully supports tall arrays. For more information, see Tall Arrays.

The floor function fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a

expand all

The floor function can calculate on all variables within a table or timetable without indexing to access those variables. All variables must have data types that support the calculation. For more information, see Direct Calculations on Tables and Timetables.