From: Oleg Komarov on
"crispin Donnelly" <odonnellracing(a)gmail.com> wrote in message <hlhkf7$kke$1(a)fred.mathworks.com>...
> Thanks Oleg, but unfortunately not...
>
> Each value in (dd) represents the magnitude and direction of displacement of a corresponding value of (a).
> These values however correspond to the values of (a) after sorting. I need to rearrange (dd) so that the values correspond to the values of (a) before sorting.
>
> Thanks in advance for any help.
> If it helps make things clearer, the application of this problems is as follows;
>
> I have a matrix (39x599) of seawater density values, within which there are instabilities (denser water lying above less dense water and vice versa). I need to quantify how far each water parcel needs to be displaced in order to make the water column stable (density increasing with depth).
> If someone can answer my original problem I can apply the solution to my density profile.
>
> Thanks once again in advance!!

See the other posts on the FEX. There are already several answers.
Oleg