Want to create table showing all possible combinations from x & y position vectorsI am provided 2 position vectors xpos and ypos. I want to create table showing all possible combinations from the x & y position vectors. I'm showing a very simple example where I want to create 2 new vectors containing all possible combinations. My issue appears to stem from the indexing but I'm stumped.
// 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
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Advanced Statistical ModelingMass CustomizationQuality and Process EngineeringRe: Want to create table showing all possible combinations from x & y position vectorsI would just use
Tables=>Join
and use the Cartesian Join capabilities to get what you want.

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" )
);Re: Want to create table showing all possible combinations from x & y position vectorsThank you! I got so wrapped around the axle that I forgot about your solution. Can I blame my lapse on today being Monday?