Info
此问题已关闭。 请重新打开它进行编辑或回答。
How do I extract certain characters using for loop?
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!