How can I create in Matlab a matrix (100 x 100) with random distribution of numbers 1 and 3, when in each column I must have 10% of numbers 1 and 90% of numbers 3? this must be random distribution.
Anyone could help me?
Thanks a ton!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
or without a
forloopThough the first one might be better if you want to explicitly control the columns differently later.
Edit: Actually, one subtle point. The first piece of code guarantees each column to have exactly 10 1’s and exactly 90 3’s. the second piece of code doen’t make this guarantee, only that the entire matrix has 1000 1’s and 9000 3’s.