Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
if in while loop not working - write combinations with unique proportions from input matrix to new matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!