How can I make a string?

1 view (last 30 days)
Noman Abir
Noman Abir on 4 Jan 2021
Commented: Noman Abir on 4 Jan 2021
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.

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 4 Jan 2021
Edited: KALYAN ACHARJYA on 4 Jan 2021
B=reshape(A,[4,3])';
C=num2str(B);
bin2dec(C)
Output :
ans =
2
10
6
Note: Loop is not necessity .
  4 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 4 Jan 2021
Thanks @Stephen
Noman Abir
Noman Abir on 4 Jan 2021
Thank You both @KALYAN & @Stephen.

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!