How to generate all possible matrices with the given entries?

3 ビュー (過去 30 日間)
Ammy
Ammy 2018 年 1 月 26 日
コメント済み: Stephen23 2018 年 1 月 26 日
I have 9 different entries (11,12,13,21,22,23,31,32,33). I want to generate all possible 3 by 3 matrices consisting of these entries with the condition that there is no repetition of any entry in any row and in any column. In short, all the 9 entries in each possible 3 by 3 matrix should be different.

回答 (1 件)

KSSV
KSSV 2018 年 1 月 26 日
val = [11,12,13,21,22,23,31,32,33] ;
A = perms(val) ;
iwant = zeros(3,3,size(A,1)) ;
for i = 1:size(A,1)
iwant(:,:,i) = reshape(A(i,:),3,3) ;
end
  1 件のコメント
Ammy
Ammy 2018 年 1 月 26 日
sorry I can't convey the full question , As in the first row of resulting matrix we get [ 33 12 23 32 13 22 21 31 11] when I split it into 3by3 matrix i have 33 12 23; 32 13 22; 21 31 11;
when I split into two matrices as ;ist digit is on the first matrix and second is on the second
i get A=[3 1 2;3 1 2; 2 3 1] B=[3 2 3; 2 3 2;1 1 1]
but I want both A and B with the conditions:
1- repetition of any row is not allowed 2- no entry out of {1,2,3} is repeated in any row , repetition in column is allowed.
I need all possible matrices with these conditions

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by