How to create a matrix with specified numbers in random positions?
Show older comments
I have a problem in Matlab that I don't really know how to approach. I need to create a matrix with specified numbers, but in random positions. So for instance, let's say I want a 20x100 matrix in which 0.2 of all numbers are 1 and 0.8 of all numbers are 0. Thus, the matrix would contain 400 ones and 1600 zeros, but in completely random positions. How to do this? (I'm sorry if this is a trivial question, I'm quite new to Matlab. I would appreciate it if you could recommend some good Matlab learning resources from which I could learn things at the level of my question).
Accepted Answer
More Answers (0)
Categories
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!