How can I incorporate values of An and Bn into matrix C? Matrix C output at the end of for loop is still values from X = randn
Afficher commentaires plus anciens
numberOfExperiments = input('Number of trials: '); %number of trials
a = {'G1' 'g1'} %heterozygous die 1 parent
b = {'G2' 'g2'} %heterozygous die 2 parent
X = randn(numberOfExperiments, 2) %random matrix to which assign genome prediction
for rows = 1:numberOfExperiments % # of rows in matrix for genome prediction
i=randperm(length(a),1) %vector with 1 integer 1
A=a(i) %picks one element from a
B=b(i) %oicks one element from b
Anew = cell2mat(A) %converts A to matrix
Bnew = cell2mat(B) %converts B to matrix
if Anew == 'g1'
An = 0
else
An = 1
end
if Bnew == 'g2'
Bn = 0
else
Bn = 1
end
for cols = 1:2 % # of cols in matrix for genome prediction
C(:,cols) = X(An, Bn)
end
C(rows, :) = X(An, Bn)
end %C is matrix with randomly selected elements from a and b to predict offspring's genome
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur App Building dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!