How to randomly select values in one matrix and make them equal to values of a second matrix?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have two separate matrices, X and Y, both containing 400 random numbers all between 1 and 20 (but X does not equal Y). I would like to create a loop that can randomly select values from X and set them equal to the value in the same position in Y, and for this loop to repeat until a certain condition is met. How would I go about setting up this loop?
0 Kommentare
Antworten (1)
the cyclist
am 27 Jan. 2020
while ... % <---- condition goes here
idx = randi(400);
x(idx) = y(idx);
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!