2's complement of a row in a matrix

3 次查看(过去 30 天)
Hi. For a = [m n] matrix, where each element value is 0 or 1. I want to get the 2's complement of rows depending on the first element value of a row. If a(m,1) = 1, then 2's complement will be performed.
How this 2's complement operation can be performed?
Any advice would be appreciated.

采纳的回答

Walter Roberson
Walter Roberson 2011-12-13
To construct the twos-complement of a binary vector, do a bit-wise negation of the vector, and then undertake the steps necessary to add 1 to the end of the vector, propagating any carry "left-ward" until there is no carry remaining.
  2 个评论
Jan
Jan 2011-12-13
Thanks, Walter. I've removed my answer.
Ayesa
Ayesa 2011-12-14
Thank you for your suggestion. It helps me to write the code. Again many thanks.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by