please in need help , how can i get all the possibile combination 111 112 121 122 211 212 221 222 for matrix A in matlab , than u

3 ビュー (過去 30 日間)
mina massoud
mina massoud 2019 年 3 月 22 日
編集済み: Stephen23 2019 年 3 月 22 日
A=[ 1 1 ; 2 2 ; 3 3 ]
  2 件のコメント
Jan
Jan 2019 年 3 月 22 日
"than u"? Is "111" a number, or do you mean the vector [1, 1, 1]? Does it matter, that the input is [1,1; 2,2; 3,3], when the posted example of the output seems to be all combinations of the numbers [1,2] with repetitions? Where is the 3 in the output?
Please edit the question and explain exactly, which inputs should produce which outputs.
mina massoud
mina massoud 2019 年 3 月 22 日
sorry i mean '' thank u ''
the input is a numebr like this
R =
1.0e+03 *
0.5807 0.5192
1.8790 1.5183
0.6836 1.5183
and i need the combianation in base 3 like 112 mean that i need the first element of the first row and the first element of the second row ah the second element of the 3rd row
so i need 8 combination , thank u

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

回答 (1 件)

Stephen23
Stephen23 2019 年 3 月 22 日
編集済み: Stephen23 2019 年 3 月 22 日
>> R = [0.5807,0.5192;0.879,1.5083;0.6836,1.5183]
R =
0.5807 0.5192
0.8790 1.5083
0.6836 1.5183
>> [X,Y,Z] = ndgrid(1:2);
>> C = [X(:),Y(:),Z(:)]
C =
1 1 1
2 1 1
1 2 1
2 2 1
1 1 2
2 1 2
1 2 2
2 2 2
>> out = R(sub2ind(size(R),repmat(1:3,8,1),C))
out =
0.5807 0.8790 0.6836
0.5192 0.8790 0.6836
0.5807 1.5083 0.6836
0.5192 1.5083 0.6836
0.5807 0.8790 1.5183
0.5192 0.8790 1.5183
0.5807 1.5083 1.5183
0.5192 1.5083 1.5183

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by