Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How do I extract certain characters using for loop?

조회 수: 2 (최근 30일)
Jake
Jake 2013년 4월 10일
마감: MATLAB Answer Bot 2021년 8월 20일
I need to extract 5 letters at a time from an input to go through a for loop. Such as if the input was 15 letters, how do I run the first five, next five, and last five at a time through for loop?

답변 (1개)

PT
PT 2013년 4월 10일
You define the loop index to increase by 5, instead of by 1.
a = 'ABCDEFGHIJKLMNO';
for i = 1:5:length(a)
b = a(i:i+4);
disp(b);
end

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by