How to compare pair of rows in a column and report it in hexadecimal format
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I have a 512x1 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 256x1 from this.
Please advise!
0 件のコメント
採用された回答
Mohammad Sami
2020 年 2 月 27 日
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);
6 件のコメント
Mohammad Sami
2020 年 2 月 27 日
response1 = oddrows > evenrows
this would give u the 256 x 1 logical vector
value would be 1 where oddrow is greater then even row and 0 otherwise.
Mohammad Sami
2020 年 2 月 27 日
If you want the values you can do the additional step
response1 = oddrows > evenrows;
values = zero(length(response1),1);
values(response1) = oddrows(response1);
values(~response1) = evenrows(~response1);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!