フィルターのクリア

How to create a matrix to contain possible combinations of 2 sets of 1D parameters

2 ビュー (過去 30 日間)
Hi,
I'd like to apply a function to all combinations of possible input parameters.
I just have 2 input parameters which are both vectors, so I'd like to create a matrix which effectively 'pairs' up my parameters.
Here's my code:
d=@(x,y) min(abs(x-y),1-abs(x-y));
x = 0:0.01:0.95;
y = 0:0.01:0.95;
Thank you!
N

採用された回答

Matt Fig
Matt Fig 2012 年 10 月 13 日
編集済み: Matt Fig 2012 年 10 月 13 日
If you mean all possible permutations, do this:
x = 0:.5:2;
I = npermutek(x,2)
I =
0 0
0 0.5000
0 1.0000
0 1.5000
0 2.0000
0.5000 0
0.5000 0.5000
0.5000 1.0000
0.5000 1.5000
0.5000 2.0000
1.0000 0
1.0000 0.5000
1.0000 1.0000
1.0000 1.5000
1.0000 2.0000
1.5000 0
1.5000 0.5000
1.5000 1.0000
1.5000 1.5000
1.5000 2.0000
2.0000 0
2.0000 0.5000
2.0000 1.0000
2.0000 1.5000
2.0000 2.0000

その他の回答 (1 件)

Matt J
Matt J 2012 年 10 月 13 日
編集済み: Matt J 2012 年 10 月 13 日
result = bsxfun(d,x(:),y);
See also the NDGRID command.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by