How to randomly select values in one matrix and make them equal to values of a second matrix?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
the cyclist
on 27 Jan 2020
while ... % <---- condition goes here
idx = randi(400);
x(idx) = y(idx);
end
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!