23 views (last 30 days)

Show older comments

Hi

Please help me how to make a 5x5 matrix whose members are all binary numbers,

For example, select the matrix even elements and then if the binary number is 1111000, convert it to 00001111, in other words, convert one to zero and convert zero to one.

r = 4×4

11001100 11011100 10000010 10010110

10100000 11011000 11010100 10011100

11011001 11001101 10001001 11001011

10001001 11111101 10011100 11111001

convert to

r = 4×4

11001100 00100011 10000010 01101001

10100000 00100111 11010100 01100011

11011001 00110010 10001001 00110100

10001001 00000010 10011100 00000110

James Tursa
on 15 Jan 2021

Mohammad Sami
on 15 Jan 2021

Edited: Mohammad Sami
on 15 Jan 2021

If your data is int / uint, you can use the function bitcmp to get the bitwise complement.

a = uint8(1);

b = bitcmp(a);

dec2bin(a,8)

dec2bin(b,8)

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

Start Hunting!