フィルターのクリア

Partition of a set.

2 ビュー (過去 30 日間)
rohini more
rohini more 2021 年 3 月 30 日
コメント済み: rohini more 2021 年 4 月 6 日
consider a partition of X= with where denotes the union of disjoint sets.
Remark that ,
I would like to implement the matlab code for above partition.
Please help me .
Thanks in advance.
  3 件のコメント
rohini more
rohini more 2021 年 3 月 30 日
Let n=7, L=4
If I split n is following way
n=1+2+3+1 according to that [n]={1}
rohini more
rohini more 2021 年 3 月 30 日
Input is n=7 and L=4
Output should be
n=1+2+3+1, [n]=
where h1=1,h2=2 ,h3=3,h4=1 and H1={1},H2={2,3}, H3={4,5,6},H4={7}

サインインしてコメントする。

採用された回答

Bruno Luong
Bruno Luong 2021 年 3 月 30 日
編集済み: Bruno Luong 2021 年 3 月 30 日
>> N=5; L=3;
>> h=allVL1(L,N-L)+1;
>> H=arrayfun(@(r) mat2cell(1:N,1,h(r,:)),(1:size(h,1))','unif',false);
>> DispPartObj(H) % FEX in my other answer
The 6 partition(s) are:
{1} {2} {3 4 5}
{1} {2 3} {4 5}
{1} {2 3 4} {5}
{1 2} {3} {4 5}
{1 2} {3 4} {5}
{1 2 3} {4} {5}
  2 件のコメント
rohini more
rohini more 2021 年 3 月 30 日
Okay.
Thank you very much.
rohini more
rohini more 2021 年 4 月 6 日
Suppose I would like to consider random partition of set what changes I have to do in this code.
Thanks in advance.

サインインしてコメントする。

その他の回答 (1 件)

Bruno Luong
Bruno Luong 2021 年 3 月 30 日
編集済み: Bruno Luong 2021 年 3 月 30 日
>> N=5; L=3;
>> DispPartObj(SetPartition(N,L))
The 25 partition(s) are:
{1 2 3} {4} {5}
{1 2 4} {3} {5}
{1 2} {3 4} {5}
{1 3 4} {2} {5}
{1 3} {2 4} {5}
{1 4} {2 3} {5}
{1} {2 3 4} {5}
{1 2 5} {3} {4}
{1 2} {3 5} {4}
{1 2} {3} {4 5}
{1 3 5} {2} {4}
{1 3} {2 5} {4}
{1 3} {2} {4 5}
{1 5} {2 3} {4}
{1} {2 3 5} {4}
{1} {2 3} {4 5}
{1 4 5} {2} {3}
{1 4} {2 5} {3}
{1 4} {2} {3 5}
{1 5} {2 4} {3}
{1} {2 4 5} {3}
{1} {2 4} {3 5}
{1 5} {2} {3 4}
{1} {2 5} {3 4}
{1} {2} {3 4 5}
  1 件のコメント
rohini more
rohini more 2021 年 3 月 31 日
Okay.
Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by