skip a number after every two number in for loop

조회 수: 2 (최근 30일)
yogi patel
yogi patel 2019년 1월 21일
댓글: yogi patel 2019년 1월 21일
Hello,
I want to execute a for loop from value 1 to 10.
but within this range I want to skip number 3, 6 and 9. could you please help with the logic of skipping specific number at regular.

채택된 답변

madhan ravi
madhan ravi 2019년 1월 21일
편집: madhan ravi 2019년 1월 21일
L=1:10;
for k = L(~ismember(L,3:3:L(end)))
k
end
  댓글 수: 4
madhan ravi
madhan ravi 2019년 1월 21일
Thank you John D‘Errico I was about to post this as another possible solution.
yogi patel
yogi patel 2019년 1월 21일
Thank you John for brief answer. Always good to know new ideas regarding simple tasks. :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by