I want to create a random matrix?
Afficher commentaires plus anciens
Help me!
I want to create a random matrix HM (3,5), it satisfies the following conditions:
1. The value of HM is a nonnegative integer from 0 to 4.
2. The total value of the elements in a row is less than or equal to 5.
Thank you very much!
3 commentaires
Wayne King
le 29 Déc 2013
Modifié(e) : Wayne King
le 29 Déc 2013
0 is not a positive integer. And why a nonnegative integer from 0 to 4? How can you select a 4 and possibly get a sum less than or equal to 3?
Pham
le 29 Déc 2013
Pham
le 29 Déc 2013
Réponse acceptée
Plus de réponses (1)
Amit
le 29 Déc 2013
0 votes
write down all possible ways to get 3 or less than 3 using integers 0-4 like [1 0 0 0 0] [1 1 0 0 0] etc.... pick one of the matrix for each row (randomly) and then use randperm to reorder them.
13 commentaires
Pham
le 29 Déc 2013
Pham
le 29 Déc 2013
Pham
le 29 Déc 2013
Pham
le 29 Déc 2013
Amit
le 29 Déc 2013
you changed the question from original post and how is 3×5 matrix matrix huge? and to make comb matrix, just make a code based on how you'll do it if you were suppose to do this on paper.
Pham
le 29 Déc 2013
Amit
le 29 Déc 2013
Then can you state your real problem please?
Amit
le 29 Déc 2013
does b, c and d have any correlation? like in the example case, you have b=c+1, d=c+1
Pham
le 29 Déc 2013
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!