MATLAB Answers

For Loop Which Skips Numbers Based on Row Vector

조회 수: 2(최근 30일)
Chad
Chad 26 Mar 2020
답변: Torsten 26 Mar 2020
I've got a row vector containing hunderds of random, ascending numbers. I need to run a for loop which skips these specific numbers. How do I write the counter?

  댓글 수: 0

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

채택된 답변

David Hill
David Hill 26 Mar 2020
n=1:1000;%not sure how far you want your for-loop to go (max(rowVector)+?)
n=n(~ismember(n,rowVector));
for k=n %or 1:length(n) indexing n(k) inside the loop.

  댓글 수: 0

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

추가 답변(1개)

Torsten
Torsten 26 Mar 2020
Use "setdiff" to remove the row vector elements from the range of the for-loop and name the vector v.
Then simply type
for v
...
end

  댓글 수: 0

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

Community Treasure Hunt

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

Start Hunting!

Translated by