比尔
比特或
描述
例子
真相表
为逻辑或操作创建真实表。
a = uint8([0 1; 0 1]);b = uint8([0 0; 1 1]);ttable = bitor(a,b)
TTable =2x2 UINT8矩阵0 1 1 1
比尔
返回1如果任何位输入为1。
negative Values
MATLAB®encodes negative integers using two's complement. For example, to find the two's complement representation of -5, you take the bit pattern of the positive version of the number (00000101
),,,,swap each bit (11111010
),,,,and then add 1 to the result (11111011
)。
因此,位或-5(-5)(11111011
)和6(00000110
)is -1 (11111111
)。
a = -5;bitget(a,8:-1:1,'int8')
ans =1×8111110 1 1
b = 6; bitget(b,8:-1:1,'int8')
ans =1×80 0 0 0 0 1 1 0
c = bitor(a,b,'int8')
C = -1
bitget(c,8:-1:1,'int8')
ans =1×81 1 1 1 1 1 1 1 1
将字节组合成32位未签名的整数
Use比尔
andbitshift
将四个8位字节打包成他们组成的32位整数。
Create four bytes of data. Specify the data with hexadecimal literals, using the-U32
suffix to specify that the data should be stored asUINT32
。每个字节包含8位价值的数据。
byte4 = 0x87u32; byte3 = 0x65u32; byte2 = 0x43u32; byte1 = 0x21u32;
首先将第一个字节添加为32位未签名整数的前8位。
包装= byte1;
接下来,将其他三个字节打包到包装
, 使用bitshift
to shift the bytes to the proper locations, and比尔
复制位。
packednum = bitor(packednum,bitshift(byte2,8));packednum = bitor(packednum,bitshift(byte3,8*2));packednum = bitor(packednum,bitshift(byte4,8*3));
查看包装的32位整数。
format十六进制包装
包装=UINT3287654321
输入参数
一种,,,,b
-输入值
scalars|vectors|matrices|multidimensional arrays
输入值,指定为标量,向量,矩阵或多维数组。输入一种
andb
必须是相同的大小或具有兼容的尺寸(例如,一种
是一个m
-by-n
矩阵和b
是一个标量或1
-by-n
行矢量)。有关更多信息,请参阅兼容阵列大小用于基本操作。一种
andb
也必须是相同的数据类型,除非一个数据类型是标量double。
如果
一种
andb
是双阵列,假设
未指定,然后是matlab®treats一种
andb
as unsigned 64-bit integers.如果
假设
is specified, then all elements in一种
andb
必须在范围内具有整数值假设
。
数据类型:双倍的
|逻辑
|int8
|int16
|int32
|INT64
|UINT8
|UINT16
|UINT32
|Uint64
假设
-假定的数据类型integ1
andinteg2
'uint64'
|'uint32'
|'uint16'
|'uint8'
|'int64'
|'int32'
|'int16'
|'int8'
假定的数据类型一种
andb
,指定为'uint64'
,,,,'uint32'
,,,,'uint16'
,,,,'uint8'
,,,,'int64'
,,,,'int32'
,,,,'int16'
, 或者'int8'
。
如果
一种
andb
是双阵列,然后假设
can specify any valid integer type, but defaults to'uint64'
。如果
一种
andb
是整数类型数组,然后假设
必须指定相同的整数类型。
数据类型:char
|细绳
NetObj1
,,,,NetObj2
-输入值
。nET enumeration objects
输入值,指定为.NET枚举对象。您必须运行Windows的版本®to use .NET enumeration objects as input arguments.
比尔
是一种由.NET枚举创建的MATLAB枚举对象的实例方法。
输出参数
C
- 位或结果
array
比特或result, returned as an array.C
与数据类型相同一种
andb
。
如果是
一种
orb
是标量double,另一个是整数类型,然后C
is the integer type.
objout
- 位或结果
。nET enumeration object
位或结果,作为.NET枚举对象返回。
扩展功能
C/C ++代码生成
Generate C and C++ code using MATLAB® Coder™.
GPU代码生成
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
HDL代码生成
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.
基于线程的环境
使用MATLAB®在后台运行代码backgroundPool
或使用并行计算工具箱加速代码™螺纹池
。
此功能完全支持基于线程的环境。金宝app有关更多信息,请参阅在基于线程的环境中运行MATLAB功能。
GPU数组
一种ccelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
用法注释和限制:
both inputs can be unsigned integer arrays, or one input can be an unsigned integer array and the other input can be a scalar double.
64-bit integers are not supported.
这
假设
argument is not supported.
有关更多信息,请参阅在GPU上运行MATLAB功能(并行计算工具箱)。
分布式阵列
使用Parallel Computing Toolbox™,将群集组合内存的组合存储器划分。
用法注释和限制:
这
假设
argument is not supported.
有关更多信息,请参阅Run MATLAB Functions with Distributed Arrays(并行计算工具箱)。
版本历史记录
Abrir Ejemplo
Tiene unaversiónmodificada de esjemplo。„ Desea abrir este ejemplo con s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s ejemplo?
Comando de Matlab
Ha Hecho Clic en ener eNRACE que对应了este comando de matlab:
Ejecute El Comando介绍了comandos de Matlab。Los Navegadores Web no Anditen comandos de Matlab。
You can also select a web site from the following list:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
美洲
- 一种mérica Latina(Español)
- 加拿大(英语)
- 美国(英语)