You are here : matlabSignal Processingdigitrevorder

digitrevorder() - Signal Processing

```digitrevorder is useful
for pre-ordering a vector of filter coefficients for use in frequency-domain
filtering algorithms, in which the fft and ifft transforms are computed without
digit-reversed ordering for improved run-time efficiency.y = digitrevorder(x,r) returns
the input data in digit-reversed order in vector or matrix y.
The digit-reversal is computed using the number system base (radix
base) r, which can be any integer from 2 to 36.
The length of x must be an integer power of r.
If x is a matrix, the digit reversal occurs on
the first dimension of x with size greater than
1. y is the same size as x. [y,i] = digitrevorder(x,r) returns
the digit-reversed vector or matrix y and the digit-reversed
indices i, such that y = x(i). Recall that MATLAB® matrices use 1-based
indexing, so the first index of y will be 1, not
0.The following table shows the numbers 0 through 15, the corresponding
digits and the digit-reversed numbers using radix base-4. The corresponding
radix base-2 bits and bit-reversed indices are also shown.Linear  IndexBase-4
DigitsDigit- ReversedDigit-
Reversed IndexBase-2  BitsBase-2 Reversed (bitrevorder)Bit-
Reversed Index
000000000000000
101104000110008
202208001001004
30330120011110012
410011010000102
5111150101101010
612219011001106
71331130111111014
820022100000011
921126100110019
10222210101001015
112332141011110113
1230033110000113
13311371101101111
14322311111001117
153333151111111115```

Syntax

`y = digitrevorder(x,r)[y,i] = digitrevorder(x,r)`

Example

```Base-3 Digit-Reversed OrderOpen This ExampleObtain the digit-reversed, radix base-3 ordered output of a vector containing 9 values. Obtain the same result by converting to base 3 and reversing the digits.x = (0:8)';

y = digitrevorder(x,3);

c1 = dec2base(x,3);
c2 = fliplr(c1);
c3 = base2dec(c2,3);

T = table(x,y,c1,c2,c3)

T =

x    y    c1    c2    c3
_    _    __    __    __

0    0    00    00    0
1    3    01    10    3
2    6    02    20    6
3    1    10    01    1
4    4    11    11    4
5    7    12    21    7
6    2    20    02    2
7    5    21    12    5
8    8    22    22    8```