How to perform XOR on a char matrix?

2 views (last 30 days)
Abirami
Abirami on 19 Apr 2015
Edited: Abirami on 19 Apr 2015
Hello,
I have a 1x5 char matrix. I need to perform a bitwise XOR operation on all the elements in the matrix.If T is the char matrix , I need a matrix T' such that
T`= T XOR (T-1)` for all T
T for T=1
Let the char matrix be T
T=['0000000000110111' '0000000001000001' '0000000001001010' '0000000010111000' '0000000000101111']
T`=['0000000000110111' '0000000001110110' '0000000000111100' '0000000010000100' '0000000010101011']
ie; Leaving the first element as such , I need to XOR all the other elements with the newly formed matrix. I tried the following code but I'm unable to get the correct result.
Yxor1d = [T(1) cellfun(@(a,b) char((a ~= b) + '0'), T(2:end), T(1:end-1), 'UniformOutput', false)]
I need to perform the XOR operation such that , for obtaining the elements of T'
T' (2)= T(2) XOR T' (1) T' (3)= T(3) XOR T' (2) and so on.
It'll be really helpful to know where I went wrong.Thanks in adavnce. Please help.

Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!