주요 콘텐츠

median

Median value of fixed-point array

Description

M = median(A) returns the median value of the fixed-point array A along its first nonsingleton dimension.

  • The fixed-point output array M has the same numerictype properties as the fixed-point input array A.

  • If the input A has a local fimath, then the local fimath is used for intermediate calculations. The output M is always associated with the default fimath

  • If A is an empty fixed-point array, the value of the output array is zero.

example

M = median(A,dim) returns the median value of the fixed-point array A along dimension dim.

Note

To compute the median value of non-fi arrays, use the median function.

example

Examples

collapse all

This example shows how to compute the median of a 2-dimensional fixed-point array.

Define a signed fi object with 32-bit word length and 27-bit (best precision) fraction length.

A = fi([0 1 2; 3 4 5; 7 2 2; 6 4 9], 1, 32)
A = 
     0     1     2
     3     4     5
     7     2     2
     6     4     9

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 32
        FractionLength: 27

Compute the median value along the first dimension.

M1 = median(A)
M1 = 
    4.5000    3.0000    3.5000

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 32
        FractionLength: 27

Compute the median value along the second dimension.

M2 = median(A,2)
M2 = 
     1
     4
     2
     6

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 32
        FractionLength: 27

The outputs M1 and M2 have the same numerictype properties as the input A.

Input Arguments

collapse all

Input data, specified as a real-valued fixed-point vector, matrix, or multidimensional array.

Example: A = fi([0 1 2; 3 4 5; 7 2 2; 6 4 9], 1, 32)

Data Types: fi

Dimension to operate along, specified as a positive integer scalar.

dim must be a positive, real-valued integer with a power-of-two slope and a bias of 0.

Extended Capabilities

expand all

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

Version History

Introduced in R2010a

See Also

| | | | |