Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对某个问题有疑问。所以,我有一个包含四个元素的三组,例如:
[r11, r12, r13, r14] [r21, r22, r23, r24] [r31, r32, r33, r34]
我需要这些元素之间的所有组合。但始终在特定集合中的每个元素都必须在同一个位置:
1. r11 r21 r31 2. r11 r21 r32 . . . n. r14 r24 r34
如何在 Matlab 或 Mathcad 中做到这一点?
假设S1, S2,你S3的:S1[r11, r12, r13, r14]
S1
S2
S3
[r11, r12, r13, r14]
[A,B,C] = ndgrid(S3, S2, S1); [C(:), B(:), A(:)]
例如输入:
S1 = [1,2]; S2 = [10,20]; S3 = [100,200,300];
结果是:
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