stroring binary string in array and perform operation using stored binary elements

i=0:1:15;
d=dec2bin(i);
s = d(2:end);
output:
d =
16×4 char array
'0000'
'0001'
'0010'
'0011'
'0100'
'0101'
'0110'
'0111'
'1000'
'1001'
'1010'
'1011'
'1100'
'1101'
'1110'
'1111'
s =
'000000011111111000011110000111100110011001100110101010101010101'
i expected/want output as follows:
s= 000 001 010 011 100 101 110 111 000 001 001 010 011 100 101 110 111
pls help me

1 件のコメント

M = dec2bin(0:15);
M(:,1) = []
M = 16×3 char array
'000' '001' '010' '011' '100' '101' '110' '111' '000' '001' '010' '011' '100' '101' '110' '111'

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

 採用された回答

chrisw23
chrisw23 2022 年 9 月 6 日
編集済み: chrisw23 2022 年 9 月 6 日

0 投票

string(d).reverse.extract(digitsPattern(3)).reverse.join(" ")
000 001 010 011 100 101 110 111 000 001 010 011 100 101 110 111

2 件のコメント

VARDIREDDY
VARDIREDDY 2022 年 9 月 6 日
移動済み: Stephen23 2022 年 9 月 6 日
thnk u very much sir
string(dec2bin(0:15)).extractAfter(1)
ans = 16×1 string array
"000" "001" "010" "011" "100" "101" "110" "111" "000" "001" "010" "011" "100" "101" "110" "111"

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Cell Arrays についてさらに検索

質問済み:

2022 年 9 月 6 日

コメント済み:

2022 年 9 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by