Info
この質問は閉じられています。 編集または回答するには再度開いてください。
if in while loop not working - write combinations with unique proportions from input matrix to new matrix
1 回表示 (過去 30 日間)
古いコメントを表示
I want to add the RGB-combinations (row in matrix P) with unique proportions (gcd=1) as a new row at the bottom of matrix Q. The code I have now (see below) isn't working though. Matlab doesn't create a new matrix Q.
N = 4;
R = 0:1:2^N-1;
R = transpose(R);
G = R;
B = R;
P = allcomb(R,G,B);
[m,n] = size(P);
i = 1;
while i <= m
i = i+1;
if gcd(P(i,1),gcd(P(i,2),P(i,3))) == 1
Q(end,:) = P(i,:);
end
2 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!