Info

This question is closed. Reopen it to edit or answer.

combination of elements of several matrix

1 view (last 30 days)
hassan
hassan on 6 May 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
I am having problem in solving combination:
There is a list of numbers with their corresponding initial digit and final digit. EXAMPLE
['1,2,3,4'] where initial digit [1] final [4]
['1,3,2,4'] where initial digit [1] final [4]
['1,5,6,7'] where initial digit [1] final [7]
['2,6,8,7,4,5'] where initial digit [2] final [5]
['2,6,8,7,9,5'] where initial digit [2] final [5]
['2,6,8,7,3,5'] where initial digit [4] final [5]
['6,6,8,7,9'] where initial digit [6] final [9]
Length of list= 4 Because ['1,2,3,4'] and ['2,6,8,7,4,5'] are having similar 2 and 3 initial and final digit respectively.
Those number [''] where initial digit []and final digit [] are similar are assumed to be in a single group (CHILDREN). it means, by running combination, same numbers having similar initial digit and final digit can not be in the same combination.
EX: ['1,2,3,4'] is in same group with ['1,3,2,4'] because initial digit [1] and final digit[4] both are same. so these 2 never can be in same combination. similarly for ['2,6,8,7,4,5']and ['2,6,8,7,9,5'] and ['2,6,8,7,3,5'] where their initial digit [2] and final digit [5] are same.
if I run combination by default, Matlab either exceeds its memory or puts similar numbers in the same combination which is the reason computation memory exceeds. My set and subsets are as follow:
set = List of numbers
subset=length (set)
combination=?????
How can write a code so that in the loop, combination of set list (children) can be created, without similar list members in a single combination? probably writing code in terms of parallel computing is more efficient solution approach.
Regards
  1 Comment
Geoff Hayes
Geoff Hayes on 6 May 2014
Hassan - please provide the code (as an attachment) that you wrote so that we can get some idea of what you tried to do to solve this problem. What commands in MATLAB did you use? perms? nchoosek?
You must also (for yourself) come up with a set of requirements that are reasonable and clear. For example, can [1 2 3 4] and [1 2 4] be in the same combination? They have different lengths but identical first and last digits. What is the maximum length for any one list of numbers? What is the set of numbers that we can choose from: 1 through 9, 1 through 100, or ..?

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!