how can i create matrix for all possible combination?

1 次查看(过去 30 天)
phi= [0.05, 0.1, 0.2, 0.5]
delta= [0.05, 0.1, 0.25, 0.5, 1.0, 2.0, 3.0]
I do need to create 4x7 =28 different combination. so final matrix should be
[0.05 0.05 ;0.05 0.1 ;0.05 0.25;.....]
something like this how can i create?

采纳的回答

Stephen23
Stephen23 2017-9-3
编辑:Stephen23 2017-9-3
Use ndgrid:
>> [deltaM,phiM] = ndgrid(delta,phi);
>> [phiM(:),deltaM(:)]
ans =
0.05 0.05
0.05 0.1
0.05 0.25
0.05 0.5
0.05 1
0.05 2
0.05 3
0.1 0.05
0.1 0.1
0.1 0.25
0.1 0.5
0.1 1
0.1 2
0.1 3
0.2 0.05
0.2 0.1
0.2 0.25
0.2 0.5
0.2 1
0.2 2
0.2 3
0.5 0.05
0.5 0.1
0.5 0.25
0.5 0.5
0.5 1
0.5 2
0.5 3

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by