concatination rows of matrix for making a new matrix

2 ビュー (過去 30 日間)
zahra hatami
zahra hatami 2020 年 12 月 2 日
コメント済み: zahra hatami 2020 年 12 月 2 日
Hi.i have a matrix(1000 * 64) that is filled with 1 and 0 .i wanna to concatinate bits of rows to make a matrix 1000 * 1 .i dont know how to do it:(

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 12 月 2 日
If you want to pack the bits to create a vector of uint64 datatype then try this
M = randi([0 1], 1000, 64); % random vector
M_new = uint64(M);
x = uint64(2).^uint64(63:-1:0);
M_new = sum(M_new.*x,2,'native');

その他の回答 (1 件)

KSSV
KSSV 2020 年 12 月 2 日
% Data for demo
A = [0 0 1 1 0 0 0
0 0 1 1 0 0 1
0 0 1 0 0 0 0];
iwant = char(A+'0');
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 12 月 2 日
But it is still 3x7 matrix. This only changes the type to char.
KSSV
KSSV 2020 年 12 月 2 日
I think OP wants to convert 1000*64 1, 0's matrix to binary representation.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by