How can I write a function that takes as input a vector of 8 bit signed integer in twos-complement and represen the negation of the input

1 次查看(过去 30 天)
How can I write a function that takes as input a vector of length eight containing 0s and 1s and representing an 8 bit signed integer in twos-complement. The function should return a vector of eight 0s and 1s representing the negation of the input.
note: I'm not allowed to use loops

回答(1 个)

Iain
Iain 2014-3-4
bin2dec, can turn a binary string into a decimal number. I suggest you then cast it as:
int8
dec2bin can then turn a decimal number into a binary string.

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by