How to generate Combination of special sets and subsets

1 回表示 (過去 30 日間)
Triveni
Triveni 2016 年 5 月 18 日
コメント済み: Jos (10584) 2016 年 5 月 19 日
a = [100, 125, 150, 175, 200, 225, 250, 275, 300, 325]; %Initial Guess
Fx(:,:,1) = [100, 125, 150, 175, 200, 225, 250, 275, 300, 325];
Fx(:,:,2) = [125, 150, 175, 200, 225, 250, 275, 300, 325, 100]; % Delete First Column and add to last
Fx(:,:,3) = [150, 175, 200, 225, 250, 275, 300, 325, 100, 125]; % Delete Second Column and add to last
Fx(:,:,4) = [175, 200, 225, 250, 275, 300, 325, 100, 125, 150];
Fx(:,:,5) = [200, 225, 250, 275, 300, 325, 100, 125, 150, 175];
Fx(:,:,6) = [225, 250, 275, 300, 325, 100, 125, 150, 175, 200];
Fx(:,:,7) = [250, 275, 300, 325, 100, 125, 150, 175, 200, 225];
Fx(:,:,8) = [275, 300, 325, 100, 125, 150, 175, 200, 225, 250];
Fx(:,:,9) = [300, 325, 100, 125, 150, 175, 200, 225, 250, 275];
Fx(:,:,10)= [300, 325, 100, 125, 150, 175, 200, 225, 250, 275];
Tx = [Fx(:,:,1),Fx(:,:,2),Fx(:,:,3),Fx(:,:,4),Fx(:,:,5),Fx(:,:,6),Fx(:,:,7),Fx(:,:,8),Fx(:,:,9),Fx(:,:,10)]; % Combine all subsets
Cx(:,:,1) = [100, 125, 150, 175, 200, 225, 250, 275, 300, 325];
Cx(:,:,2) = [125, 150, 175, 200, 225, 250, 275, 300, 325];
Cx(:,:,3) = [150, 175, 200, 225, 250, 275, 300, 325];
Cx(:,:,4) = [175, 200, 225, 250, 275, 300, 325];
Cx(:,:,5) = [200, 225, 250, 275, 300, 325];
Cx(:,:,6) = [225, 250, 275, 300, 325];
Cx(:,:,7) = [250, 275, 300, 325];
Cx(:,:,8) = [275, 300, 325];
Cx(:,:,9) = [300, 325];
Cx(:,:,10)= [300];
Tc = [Cx(:,:,1),Cx(:,:,2),Cx(:,:,3),Cx(:,:,4),Cx(:,:,5),Cx(:,:,6),Cx(:,:,7),Cx(:,:,8),Cx(:,:,9),Cx(:,:,10)];
%Please help me to find Tx and Tc

採用された回答

Jos (10584)
Jos (10584) 2016 年 5 月 18 日
編集済み: Jos (10584) 2016 年 5 月 18 日
This is called a circulant matrix. I have written a function that can be found in the File Exchange:
A = [100 125 300 400]
B = circulant(A,-1)
tf = flipud(tril(true(size(B))))
C = B(tf)
  2 件のコメント
Triveni
Triveni 2016 年 5 月 18 日
編集済み: Triveni 2016 年 5 月 18 日
Can you combine it(in Tx) automatically
a = [100, 125, 150, 175, 200, 225, 250, 275, 300, 325];
for k = 1: numel(a)
Fx{:,:,k} = a(k:numel(a))
end
Tx = [Fx{:,:,1},Fx{:,:,2},Fx{:,:,3},Fx{:,:,4},Fx{:,:,5},Fx{:,:,6},Fx{:,:,7},Fx{:,:,8},Fx{:,:,9},Fx{:,:,10}];
%
Jos (10584)
Jos (10584) 2016 年 5 月 19 日
Why are you using 3D cell arrays?

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

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2016 年 5 月 18 日
編集済み: Jos (10584) 2016 年 5 月 18 日
Found both of them :D
  2 件のコメント
Jos (10584)
Jos (10584) 2016 年 5 月 18 日
Sorry, lame joke. But I did not understand your question. Can you rephrase it?
Triveni
Triveni 2016 年 5 月 18 日
I want to solve it from loop. or any good way instead of manual solution. i need combination Fx and combine all Fx into Tx
Tx =
Columns 1 through 27
100 125 150 175 200 225 250 275 300 325 125 150 175 200 225 250 275 300 325 100 150 175 200 225 250 275 300
Columns 28 through 54
325 100 125 175 200 225 250 275 300 325 100 125 150 200 225 250 275 300 325 100 125 150 175 225 250 275 300
Columns 55 through 81
325 100 125 150 175 200 250 275 300 325 100 125 150 175 200 225 275 300 325 100 125 150 175 200 225 250 300
Columns 82 through 100
325 100 125 150 175 200 225 250 275 300 325 100 125 150 175 200 225 250 275
and Tc (combine all combination). I am unable to calculate Tc.

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

カテゴリ

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