필터 지우기
필터 지우기

a question on inner loops

조회 수: 1 (최근 30일)
Mnr
Mnr 2016년 3월 7일
답변: John D'Errico 2016년 3월 7일
Hello all,
I would like to have 2 for loops such that the outer 1 counts i=1:M and the inner one from j=1:M but j~=i. How can I program this in Matlab? In other words, I would like to have something like
if true
for i=1:M
for j=1:M && j~=i
code
end
end
end

채택된 답변

John D'Errico
John D'Errico 2016년 3월 7일
Easy.
for j = setdiff(1:M,i)

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by