If you are talking about the wiki page, http://sourceforge.net/apps/mediawiki/pdl/index.php?title=PDL_for_Matlab_users
send me your sf.net user id and I can add you as an editor. --Chris On Fri, Jan 25, 2013 at 2:44 AM, Lee <[email protected]> wrote: > Thanks. I just tried logging in to SourceForge to put this (and which) on > the Perl for Matlab page, but although I am logged in to SF, there is no > edit link on the project page. Is this something for which I need to apply? > > > On 24/01/2013 17:43, David Mertens wrote: >> >> I only briefly touched on "where". The "where" function is pretty awesome >> compared with Matlab because you can actually save the "slice" in a variable >> and manipulate it later. In Matlab, as I recall, you can only manipulate a >> slice on the line in which the slice is created. In PDL, you can store the >> slice in a variable and manipulate it later. >> >> $a = sequence(20); >> $b = $a->where($a % 2 == 0); >> # Make all even values in $a odd: >> $b += 1; >> >> >> On Thu, Jan 24, 2013 at 10:40 AM, David Mertens <[email protected] >> <mailto:[email protected]>> wrote: >> >> Just to clarify, here's something out of the pdl shell: >> >> # make 20 values from -9 to 10 >> pdl> $a = zeroes(20)->xlinvals(-9, 10) >> pdl> p $a >> [-9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10] >> >> # get a mask of true/false >> pdl> p $a == 4 >> [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0] >> >> # Get that offset: >> pdl> p which($a == 4) >> [13] >> >> # Mask all values that are even: >> pdl> p $a % 2 == 0 >> [0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1] >> >> # Get those indices >> pdl> p which($a % 2 == 0) >> [1 3 5 7 9 11 13 15 17 19] >> >> # Flip the sign of even values >> pdl> $a->where($a % 2 == 0) *= -1 >> pdl> p $a >> [-9 8 -7 6 -5 4 -3 2 -1 0 1 -2 3 -4 5 -6 7 -8 9 -10] >> >> # learn about approx: >> pdl> ? approx >> # use it for floating point numbers >> pdl> $a = sequence(20)->sqrt >> pdl> p $a >> [0 1 1.4142136 1.7320508 2 2.236068 2.4494897 2.6457513 >> 2.8284271 3 3.1622777 3.3166248 3.4641016 3.6055513 3.7416574 >> 3.8729833 4 4.1231056 4.2426407 4.3588989] >> >> # Find the square root of 2, approximately: >> pdl> p $a->approx(1.414) >> [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] >> >> # The default epsilon, 1e-6, is too strict. >> # Find where $a is approximately 1.414, within 1e-3 >> pdl> p $a->approx(1.414, 1e-3) >> [0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] >> >> # Later calls to approx use same "epsilon" that we just set: >> pdl> p $a->approx(1.414) >> [0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] >> >> # Get the index thereof >> pdl> p which($a->approx(1.414)) >> [2] >> >> Hope that helps! >> >> >> On Thu, Jan 24, 2013 at 10:23 AM, Lee Goddard <[email protected] >> <mailto:[email protected]>> wrote: >> >> Thanks. >> >> >> On 24/01/2013 15:50, Chris Marshall wrote: >> >> which or whichND >> >> On Thu, Jan 24, 2013 at 9:46 AM, Lee Goddard >> <[email protected] <mailto:[email protected]>> wrote: >> >> Is there a PDL equivalant to MATLAB's 'find(x)' >> function, or will I need to >> write my own? >> >> TIA >> Lee >> >> ind = find(X) >> locates all nonzero elements of array X, and returns >> the linear indicies of >> those elements in vector ind. If X is a row vector, >> then ind is a row >> vector; otherwise, ind is a column vector. If X >> contains no nonzero elements >> or is an empty array, then ind is an empty array. >> >> -- http://www.mathworks.com/help/matlab/ref/find.html >> >> >> _______________________________________________ >> Perldl mailing list >> [email protected] <mailto:[email protected]> >> >> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >> >> >> >> _______________________________________________ >> Perldl mailing list >> [email protected] <mailto:[email protected]> >> >> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >> >> >> >> >> -- "Debugging is twice as hard as writing the code in the first >> place. >> Therefore, if you write the code as cleverly as possible, you are, >> by definition, not smart enough to debug it." -- Brian Kernighan >> >> >> >> >> -- >> "Debugging is twice as hard as writing the code in the first place. >> Therefore, if you write the code as cleverly as possible, you are, >> by definition, not smart enough to debug it." -- Brian Kernighan >> >> >> _______________________________________________ >> Perldl mailing list >> [email protected] >> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > > > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
