필터 지우기
필터 지우기

code without for loop

조회 수: 1 (최근 30일)
Sajid
Sajid 2012년 12월 5일
Hi,
i have an index variable. Each row contains an x,y coordinate. i can loop through each x,y and set value. but i cannot achieve this without for loop. Can anyone tell me how to run this code without for loop?
for i=1:size(index,1)
mask(index(i,1),index(i,2)) = 255;
end
Thanks,
Sajid

답변 (1개)

Matt Fig
Matt Fig 2012년 12월 5일
idx = sub2ind(size(mask),index(:,1),index(:,2));
mask(idx) = 255;

카테고리

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