matlab中位操作倒序函数bitrevorder怎么用?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了matlab中位操作倒序函数bitrevorder怎么用?相关的知识,希望对你有一定的参考价值。

想要的效果是输入4(100)得到1(001),但是结果还是4.
想要的效果是输入4(100)得到1(001),但是结果还是4.

看了说明,没太明白。
帮助里举的例子是数组,有参数是一个数的函数吗?

先用dec2bin把10进制数按位宽转为2进制字符串,再左右翻转字符串,再把得到的2进制字符串转为10进制数:
bin2dec(fliplr(dec2bin(4,3)))
ans =
1
参考技术A

    先用dec2bin把10进制数按位宽转为2进制字符串,再左右翻转字符串,再把得到的2进制字符串转为10进制数:
    bin2dec(fliplr(dec2bin(4,3)))
    ans =
        1

参考技术B 代码如下
clc;
a=[1 3 5 7];
a1=bitshift(a,3)
dec2bin(a1)
a2=bitshift(a,3,1)
dec2bin(a2)

a2=bitshift(a,3,2)
dec2bin(a2)

a2=bitshift(a,3,3)
dec2bin(a2)

a2=bitshift(a,3,4)
dec2bin(a2)

a2=bitshift(a,3,5)
dec2bi
Matlab的两种移位运算:

1) circshift 矩阵移位
circshift :Shift array circularly
Syntax : B = circshift(A,shiftsize)
Description :
B = circshift(A,shiftsize) circularly shifts the values in the array, A, by shiftsize elements. shiftsize is a vector of integer scalars where the n-th element specifies the shift amount for the n-th dimension of array A. If an element in shiftsize is positive, the values of A are shifted down (or to the right). If it is negative, the values of A are shifted up (or to the left). If it is 0, the values in that dimension are not shifted.

Example :
Circularly shift first dimension values down by 1.
A = [ 1 2 3;4 5 6; 7 8 9]
A =
1 2 3
4 5 6
7 8 9
B = circshift(A,1)
B =
7 8 9
1 2 3
4 5 6

Circularly shift first dimension values down by 1 and second dimension values to the left by 1.
B = circshift(A,[1 -1]);
B =
8 9 7
2 3 1
5 6 4

2)bitshift 位移位
bitshift :
Shift bits specified number of places

Syntax :
C = bitshift(A, k)
C = bitshift(A, k, n)

Description :
C = bitshift(A, k) returns the value of A shifted by k bits. Input argument A must be an unsigned integer or an array of unsigned integers. Shifting by k is the same as multiplication by 2^k. Negative values of k are allowed and this corresponds to shifting to the right, or dividing by 2^abs(k) and truncating to an integer. If the shift causes C to overflow the number of bits in the unsigned integer class of A, then the overflowing bits are dropped.
C = bitshift(A, k, n) causes any bits that overflow n bits to be dropped. The value of n must be less than or equal to the length in bits of the unsigned integer class of A (e.g., n <= 32 for uint32).
Instead of using bitshift(A, k, 8) or another power of 2 for n, consider using bitshift(uint8(A), k) or the appropriate unsigned integer class for A.

Examples:

Example 1
Shifting 1100 (12, decimal) to the left two bits yields 110000 (48, decimal).
C = bitshift(12, 2)
C =
48

Example 2

Repeatedly shift the bits of an unsigned 16 bit value to the left until all the nonzero bits overflow. Track the progress in binary:
a = intmax('uint16');
disp(sprintf( ...
'Initial uint16 value %5d is %16s in binary', ...
a, dec2bin(a)))
for k = 1:16
a = bitshift(a, 1);
disp(sprintf( ...
'Shifted uint16 value %5d is %16s in binary',...
a, dec2bin(a)))
end

n(a2)

以上是关于matlab中位操作倒序函数bitrevorder怎么用?的主要内容,如果未能解决你的问题,请参考以下文章

Matlab中每n个值的中位数

matlab中使用fft(x)方法求得的64点的频率输出是否倒序的?

numpy中位操作函数和比较函数

使用MATLAB进行中位数,四分位数,四分位数跨度和分辨率

求基于matlab的EMD代码,急!

python 中一维数据中值滤波函数,在matlab中有 medfilt1函数,Python中有吗,只找到了图像2维的,