I have a text file with points coordinates.
X1 Y1
X2 Y2
X3 Y3
...
Xn Yn
The idea is to build a matrix of this coordinates.
I coded a first version that reads the X and Y values, push them into respectively @Xs and @Yx array, and then create the matrix using
$Points = PDL::Matrix->pdl([\@Xs, \@Ys]);
I then get a 2 x n Matrix :
[
[X1, X2, X3, .., Xn]
[Y1, Y2, Y3, .., Yn]
]
I now would like to build a n x 2 Matrix instead :
[
[X1, Y1]
[X2, Y2]
...
[Xn, Yn]
]
but I don't see how I can do it as the push fonction seems not to exist for PDL::Matrix
Thank you for your help,
EDIT 1 :
Here is what I would like to do :
sub GetCoordinates {
my (@hl) = @_;
my $Point;
my $Points;
foreach my $v (@hl)
{
my %values = ($v =~ m/${regex_Coordinates}/g);
if ($values{X} && $values{Y})
{
$Point = mpdl [$values{X},$values{Y}];
push($Points, $Point); # DOES NOT EXIST
}
}
}