how can i create matrix for all possible combination?

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Stephen23
Stephen23 il 3 Set 2017
Modificato: Stephen23 il 3 Set 2017
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

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by