How to create a function in Matlab or Mathcad for combination of all elements betweeen three sets -
this question has answer here:
i have problem issue. so, have 3 sets 4 elements, e.g.:
[r11, r12, r13, r14] [r21, r22, r23, r24] [r31, r32, r33, r34]
i need combination between these elements. each of elements in particular sets must in same place:
1. r11 r21 r31 2. r11 r21 r32 . . . n. r14 r24 r34
how can in matlab or mathcad?
assuming sets s1
, s2
, s3
s1
[r11, r12, r13, r14]
:
[a,b,c] = ndgrid(s3, s2, s1); [c(:), b(:), a(:)]
for example input:
s1 = [1,2]; s2 = [10,20]; s3 = [100,200,300];
results in:
ans = 1 10 100 1 10 200 1 10 300 1 20 100 1 20 200 1 20 300 2 10 100 2 10 200 2 10 300 2 20 100 2 20 200 2 20 300
Comments
Post a Comment