How can I make a string?

2 ビュー (過去 30 日間)
Noman Abir
Noman Abir 2021 年 1 月 4 日
コメント済み: Noman Abir 2021 年 1 月 4 日
I have some values as : A=
0
0
1
0
1
0
1
0
0
1
1
0
I want to take every 4 values in a string.
Output should be : B =
0 0 1 0
1 0 1 0
0 1 1 0
And, after that I want to covert the values from binary to decimal.
Final output should be :
2
10
6
It cuould be better for me if it is done in a loop. Because, I have a length of "A" near 40+ lacs.

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 1 月 4 日
編集済み: KALYAN ACHARJYA 2021 年 1 月 4 日
B=reshape(A,[4,3])';
C=num2str(B);
bin2dec(C)
Output :
ans =
2
10
6
Note: Loop is not necessity .
  4 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 1 月 4 日
Thanks @Stephen
Noman Abir
Noman Abir 2021 年 1 月 4 日
Thank You both @KALYAN & @Stephen.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by