Hello, I want a function that does the following processing: for example I have two strings :
S = '011011000000111000000010001'
B = '23352534'
The result I want to have is :
01 --> 2 caractères
101 --> 3 caractères
100 --> 3 caractères
00001 --> 5 caractères
11 --> 2 caractères
00000 --> 5 caractères
001 --> 3 caractères
0001 --> 4 caractères
In other words I want to divide the string S according to the number B. How to do this?

 채택된 답변

Guillaume
Guillaume 2017년 9월 29일

3 개 추천

mat2cell(S, 1, B - '0')
is probably the simplest way to do it

댓글 수: 3

Stephen23
Stephen23 2017년 9월 29일
+1 very nice
Jan
Jan 2017년 9월 29일
+1 perfect
abdelkader bouguessa
abdelkader bouguessa 2017년 9월 29일
Thank You Sir! It works.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by