How to make a certain percentage of values in an existing matrix, between a set range of values. Probably easy but I am a newbie.
2 views (last 30 days)
Show older comments
Kelley Kehoe on 3 Oct 2020
So I have these commands in my script to create a 25x10 matrix of randomly assigned values between 50 and 100. However I need to make 10% of those randomly assigned values between 30 and 50, with the ability to change the percentage at will. Any help would be great.
Rub Ron on 3 Oct 2020
What about this:
my_percentage = 10;
my_piece = prod(size)*my_percentage/100;
rand_idx = randperm(prod(size),my_piece);
More Answers (0)
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!