MATLAB Answers

how to change the bit of any matrix?

1 view (last 30 days)
Sultan Mehmood
Sultan Mehmood on 1 Jul 2019
Answered: Shameer Parmar on 1 Jul 2019
A=[12 32 ;23 14];
>> D=A(:)';
>> S=de2bi(D);
>> S=de2bi(D)
S =
0 0 1 1 0 0
1 1 1 0 1 0
0 0 0 0 0 1
0 1 1 1 0 0
>> i want to make its 4th bit zero.. so what will i do?

  0 Comments

Sign in to comment.

Accepted Answer

Jan
Jan on 1 Jul 2019
Edited: Jan on 1 Jul 2019
A = [12, 23, 32, 14];
B = bitset(A, 4, 0)
Or:
S = de2bi(A);
S(:, 4) = 0;

  0 Comments

Sign in to comment.

More Answers (1)

Shameer Parmar
Shameer Parmar on 1 Jul 2019
try with this..
S(:,4) = 0

  0 Comments

Sign in to comment.

Sign in to answer this question.