
How to convert string or chars to string arrays withing for loop?
조회 수: 2 (최근 30일)
이전 댓글 표시
How could I convert message to string array withing for loop? Each string in array has to be 4 characters long. For example:
message = 'SOMETEXT';
for i = 1:4:length(message)
%some code here
end
Outcome would be:
out = ["SOME", "TEXT"];
Many thanks
댓글 수: 0
채택된 답변
KALYAN ACHARJYA
2019년 11월 4일
편집: KALYAN ACHARJYA
2019년 11월 4일
message ='SOMETEXT';
l=1;
for i=1:4:length(message)
result{l}=message(i:i+3);
l=l+1;
end
result
You asked for for loop (specifically)

댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!