Hello Daniel, I'm not entirely sure what you're trying to do, so I can't answer by changing your supplied code. I can, however, point out a couple of things.
PDL does not have a straight equivalent to matlab's start:step:end notation, at least not for pdl creation. The slicing notation does allow you to specify strides using a start:end:stride notation: --------%<-------- use strict; use warnings; use PDL; use PDL::NIceSlice; my $original = sequence(20); my ($start, $end, $stride) = (2, 19, 3); my $slice = $original($start:$end:$stride); -------->%-------- Craig already mentioned xvals, rvals, and the others. Something that is even closer to what you want is the set of functions xlinvals(start, stop), ylinvals(start, stop), zlinvals(start, stop). Like xvals and rvals, these functions are not constructors; they take the invoking pdl and use it as a template, computing the necessary spacing so that the first value is $start and the last value is $stop, with linear steps in between them. That means you'll have to determine the number of elements and create a template pdl separately, like this: --------%<-------- use strict; use warnings; use PDL; my ($start, $end, $step) = (2, 19, 0.1); my $N_elements = int (abs($end - $start) / $step) + 1; my $pdl = zeroes($N_elements); $pdl .= $pdl->xlinvals($start, $end); -------->%-------- This code does not handle edge cases very well. For example, if the step does not divide evenly into $end - $start, then the resulting pdl will not have the specified stride. However, hopefully it will get you started. Perhaps the two-argument form of xlinvals et al can be extended to a three argument form, which would actually be a constructor and would do what the Matlab constructor does. David -- Sent via my carrier pigeon. _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
