How to concatenate binary strings?

21 ビュー (過去 30 日間)
Ammy
Ammy 2022 年 3 月 8 日
コメント済み: Ammy 2022 年 3 月 8 日
I have binary data 8192x8 char
'00000010'
'01101111'
'00111001'
'00111111'
'11010110'
'01000110'
'10100010'
.......
I want to cocatenate (1:32) , (33:64), (65:96),.... strings
Let first string be a='00000010',
second string be b= '01101111'
strcat(a,b) results '0000001001101111',
But I want to concatenate first 32 strings and so on...

採用された回答

David Hill
David Hill 2022 年 3 月 8 日
A=A';
A=reshape(A,256,[]);%each column will now be your desired arrays, you could transpose again if you wanted rows being your desired arrays

その他の回答 (2 件)

Benjamin Thompson
Benjamin Thompson 2022 年 3 月 8 日
編集済み: Benjamin Thompson 2022 年 3 月 8 日
Something like this. Just change the size arguments passed to reshape as needed:
A = [ '00000010'
'01101111'
'00111001'
'00111111'
'11010110'
'01000110'
'10100010'];
A = [A; '11111111'];
A = [A; A; A; A];
A2 = reshape(A(:),8,32)
A2 =
8×32 char array
'00000000000000000000000011110000'
'00001111111100001111111111111111'
'00000000111111111111000000001111'
'00000000111111111111111111111111'
'11111111000011110000111111110000'
'00001111000000000000111111110000'
'11110000111100000000000011110000'
'11111111111111111111111111111111'

Jan
Jan 2022 年 3 月 8 日
編集済み: Jan 2022 年 3 月 8 日
s = char('0' + randi([0,1], 8192, 8)); % Some test data
r = reshape(s.', 32 * 8, []).'; % Create a 256 x 256 matrix
  1 件のコメント
Ammy
Ammy 2022 年 3 月 8 日
Very thankful to all of you for the valuable comments.

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by