想要创建表格来显示 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 位置向量的所有可能组合谢谢!我太纠结于轴的问题了,忘记了你的解决方案。我能把我的疏忽归咎于今天是星期一吗?