How to randomly select values in one matrix and make them equal to values of a second matrix?

1 visualización (últimos 30 días)
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?

Respuestas (1)

the cyclist
the cyclist el 27 de En. de 2020
while ... % <---- condition goes here
idx = randi(400);
x(idx) = y(idx);
end

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by