想要建立表格來顯示 x 和 y 位置向量的所有可能組合我有兩個位置向量 xpos 和 ypos。我想建立一個表格,顯示 x 和 y 位置向量的所有可能組合。我展示了一個非常簡單的範例,其中我想建立兩個包含所有可能組合的新向量。我的問題似乎源自於索引,但我被難住了。
// Want to create table showing all possible combinations from x & y position vectors
xpos={1, 2, 3, 4, 5};
ypos={7, 8, 9 };
xloc={};
yloc={};
// Loop through x positions
for(i=1, i<=NItems(xpos), i++,
// Loop through y positions
for(j=1, j<=NItems(ypos),j++,
insert into(xloc, xpos);
insert into(yloc, ypos, j);
);
//print(i);
);
xloc;
yloc;
dt = new table("All Combos");
dt << new column("X", continuous, values(xloc));
dt << new column("Y", continuous, values(y));
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Want a table that looks like this:
X Y
1 7
1 8
1 9
2 7
2 8
2 9
.
.
.
5 7
5 8
5 9
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
進階統計建模大規模客製化品質與工藝工程回复:想要創建表格以顯示 x 和 y 位置向量的所有可能組合我只會用
表格=>加入
並使用 Cartesian Join 功能來獲得您想要的。

names default to here(1);
xpos={1, 2, 3, 4, 5};
ypos={7, 8, 9 };
dt1 = new table("One", new column("x"));
dt1:x << set values(xpos);
dt2 = new table("Two", new column("y"));
dt2:y << set values(ypos);
dtCart = dt1 << Join(
With( dt2 ),
Cartesian Join,
Output Table( "Final" )
);回覆:想要建立顯示 x 和 y 位置向量的所有可能組合的表格謝謝你!我被車軸纏住了,以至於我忘了你的解決方案。我能把我的失誤歸咎於今天是星期一嗎?