matlab de2bi
时间: 2023-10-16 19:29:55 浏览: 206
The MATLAB function de2bi() converts decimal numbers to binary numbers.
Syntax:
```
B = de2bi(D)
B = de2bi(D, N)
```
Inputs:
- D: Decimal input as a scalar, vector, or matrix.
- N: Optional parameter that specifies the number of bits to use in the binary representation. If N is not specified, the function uses the smallest number of bits to represent the input.
Outputs:
- B: Binary output as a matrix of 0s and 1s. Each row corresponds to the binary representation of an element in D.
Example usage:
```
>> D = [10 15 7];
>> B = de2bi(D)
B =
1 0 1 0
1 1 1 1
0 1 1 1
```
This code converts decimal numbers 10, 15, and 7 to their binary representation. The output matrix B has three rows, each corresponding to the binary representation of an input element.
阅读全文