Filter löschen
Filter löschen

how to xor binary vector in matrix

3 Ansichten (letzte 30 Tage)
jim
jim am 18 Okt. 2014
Bearbeitet: jim am 24 Okt. 2014
hello.. i have

Akzeptierte Antwort

Roger Stafford
Roger Stafford am 18 Okt. 2014
If I understand what you want and if the rows have a multiple of three elements, this should work for you:
X = xor(xor(M(:,1:3:end-2),M(:,2:3:end-1)),M(:,3:3:end));
If this is not what you want, you should clarify that phrase "every three bits together" so that it is clearly understood. As it stands, it is easily misunderstood. It should be simple to make it clear what you mean if you carefully construct a good, meaningful example.
  4 Kommentare
Roger Stafford
Roger Stafford am 18 Okt. 2014
When you used the word 'last' I thought you wanted the extra zeros appended to the right end. Apparently you want them appended to the left end. If that is the case, just reverse the order:
[m,n] = size(M);
M2 = [zeros(m,3*ceil(n/3)-n),M];
X = xor(xor(M2(:,1:3:end-2),M2(:,2:3:end-1)),M2(:,3:3:end));
jim
jim am 19 Okt. 2014
thank you very much,, it works fine

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by