MATLAB: How to compare pair of rows in a column and report it in hexadecimal format

comparehexadecimalmatrixrows

Hello,
I have a 512×1 matrix (512 rows and 1 column)
The value of ROW1 should be compared with ROW2, similarly ROW3 with ROW4, etc. I have to compute this 256-bit response and report it in hexadecimal format assuming; if ROW1 > ROW2 then 1 & if ROW2 > ROW1 then 0
In this way I will get 256×1 from this.
Please advise!

Best Answer

data = rand(512,1);
oddrows = data(1:2:end);
evenrows = data(2:2:end);
response1 = oddrows > evenrows;
response2 = evenrows > oddrows;
response1 = char(response1' + '0');
response2 = char(response2' + '0');
% download bin2hex function from matlab file exchange
% https://www.mathworks.com/matlabcentral/fileexchange/1975-bin2hex
response1hex = bin2hex(response1);
response2hex = bin2hex(response2);