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!