I want to generate all possible combinations of 3*3 matrix, where the sum of all elements of this matrix equal 10.
2 views (last 30 days)
Show older comments
I want to generate all possible combinations of 3*3 matrix, where the sum of all elements of this matrix equal 10.
2 Comments
Fangjun Jiang
on 8 Aug 2018
you have to provide with more constraints such as all integer numbers and what range? Otherwise, the possibility is infinite.
Answers (1)
Fangjun Jiang
on 8 Aug 2018
Edited: Fangjun Jiang
on 8 Aug 2018
Then you probably mean "one way" to generate the matrix, not "all possible combinations". The one way below does not even consider any negative numbers
a=rand(3);
a=a*10/sum(a(:))
sum(a(:))
0 Comments
See Also
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!