Choosing a random number from a linearly spaced vector
5 views (last 30 days)
Show older comments
I get the error as size inputs must be scalar. I want to choose one random value from the linearly spaced set of values for every trial. So, everytime I run yy, I should get a random value from the xx vector. Please help on how I go about it.
xx= linspace(1,2,9) %a vector of linearly spaced values
yy= randperm(xx) %pick a random value from xx
0 Comments
Accepted Answer
KSSV
on 17 Jan 2022
xx= linspace(1,2,9) %a vector of linearly spaced values
yy = xx(randi(9,1))
0 Comments
More Answers (0)
See Also
Categories
Find more on Statistics and Machine Learning Toolbox 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!