Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to do a loop for a number to determine what color to use?

1 回表示 (過去 30 日間)
Valeria Chacon
Valeria Chacon 2016 年 11 月 20 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
theta=zeros(N,N);
theta = mod(bsxfun(@plus, (1:N), (1:N).'),2);
In this case, N is the input that the user chooses. At this point it gives me a matrix theta=[0,1,0,1 ; 1,0,1,0 ; 0,1,0,1 ; 1,0,1,0] and I was wondering how I could do a loop so that when theta=0 it will use color1 and when theta=1 it will use color2. (in this case, color1 and 2 are also inputted by the user)

回答 (1 件)

Image Analyst
Image Analyst 2016 年 11 月 20 日
Try this inside your loop:
if theta(row, column) == 0
colorToUse = color1;
else
colorToUse = color2;
end

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by