필터 지우기
필터 지우기

replacing a for loop

조회 수: 1 (최근 30일)
Mnr
Mnr 2015년 11월 28일
댓글: Mnr 2015년 11월 29일
Hello all,
I have a simple piece of code that I would like to get rid of the for loop. I would appreciate your help.
for n=1:K
idx=row((((n-1)*dc)+1):(n*dc));
end
where as an example K=4, dc=2, and row=[1;3;2;3;1;4;2;4];

채택된 답변

Walter Roberson
Walter Roberson 2015년 11월 28일
t = reshape(row, dc, []);
idx = t(:,1:K);
  댓글 수: 1
Mnr
Mnr 2015년 11월 29일
Thank you!

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

추가 답변 (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