I think I mixed up the data tables at the end of the script, try this:

```
dt1=New Table( "Table 1",
Add Rows( 20 ),
New Column( "x",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() )
),
New Column( "y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() )
),
Set Row States( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0] )
);
wait(0.0);
dt1:x << suppress eval( true );
dt1:y << suppress eval( true );
dt2=New Table( "Table 2",
Add Rows( 20 ),
New Column( "x",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() ),
Set Display Width( 120 )
),
New Column( "y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() ),
Set Selected,
Set Display Width( 118 )
),
Set Row States( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0] )
);
wait(0.0);
dt2:x << suppress eval( true );
dt2:y << suppress eval( true );
M1 = dt1 << GetAsMatrix();
MD1=vptree(M1);
M2 = dt2 << GetAsMatrix();
MD2=kdtable(M2);
//returns the nearest point of Table 1 to a point in table 2
//to reverse the look up, make MD1-> MD2 and M2->M1
{rows, dist} = MD1 << K nearest rows( 1, M2);
dt2<<new column("same as rows",
Numeric,
Ordinal,
Set Values( rows )
);
dt1<<new column("row number",
Numeric,
Ordinal,
Formula(Row())
);
```

I virtual linked them and did some visual checks so I believe we are good now