How many Possible cases
Ältere Kommentare anzeigen
Think we have few strams. n cold and m hot. How many cases are possible that they can face each other?
I want to program it on matlab,and save all cases in another matrix,then use that matrix as a feed of another operation.
Anyone knows how write it on matlab?
I’m not sure but I think for 2 cold and 2 hot strams there is 4 cases possible like below:

4 Kommentare
Torsten
am 23 Apr. 2019
There are n! possibilities to order the cold streams and m! possibilities to order the hot streams. Thus there should be n! * m! possibilities they can face each other, I guess.
John D'Errico
am 23 Apr. 2019
you can compute all the permutations using perms. So
perms(1:3)
ans =
3 2 1
3 1 2
2 3 1
2 1 3
1 3 2
1 2 3
Beware that the result of perms will get huge for large n. And if you are then wanting to compute all combinations of two sets, that gets even more huge.
So if n=m=10, means you apparently want to compute an array that is effectively of size n!*m!*(n+m).
S = factorial(10)*factorial(10)*20
S =
2.6336e+14
If each element is a double, that would be on the order of 2.1e6 gigabyes of RAM to store. So 2.1 petabytes?
Many times people want to do things that are computationally impossible, generating all such combinations. This is usually a signal they are trying to use a brute force way to compute a solution. At the same time, much of mathematics is devoted to finding alternative ways to avoid the need for brute force. For example, there are integer programming solvers that solve a problem without investigating every possible set of permissible solutions. So if your goal is to do this for large problems, I would suggest you look for alternatives. While brute force is indeed a possible approach, it is rarely a happy one for really large problems.
Amy Hs
am 23 Apr. 2019
Antworten (0)
Kategorien
Mehr zu Common Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!