How to do xor operation in cell arrays?
Show older comments
Suppose,
A={'d9' '31'};
B={'42' '83'};
The expected output is:
Y={'42' '83'}
My input will not be the same always. So,how can I write a useful matlab code for each inputs?
6 Comments
How is this different to your previous questions (with answers)?:
???
Darsana P M
on 21 Nov 2017
Darsana P M
on 21 Nov 2017
Jan
on 21 Nov 2017
@Dorsana: Please do not let us guess, what the inputs are. 'd9' might mean, that this is a string representing a hex value.
Now check the values of 'd9' and '42'
hex dec bin
d9 217 11011001
42 66 01000010
XOR'ed:
9b 155 10011011
I have no idea, why you expect '42' as output. The '31' for the 2nd column is strange also. This is no XOR operation.
By the way: You can convert the values easily using hex2dec and dec2bin, such that the shown links should help already.
Darsana P M
on 21 Nov 2017
Darsana P M
on 21 Nov 2017
Edited: Walter Roberson
on 21 Nov 2017
Accepted Answer
More Answers (1)
Walter Roberson
on 21 Nov 2017
0 votes
Earlier, I showed you how to do the xor on character vectors. From this you can see how to do the xor operation.
Early this morning, I showed you how to do addition with cell arrays. From this you can see how to extract inputs from cell arrays of character vectors and how to output back to cell arrays.
Now just put those two operations together. Use the data import and output from the addition code and use the xor from the xor code.
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!