For completeness, here is an excerpt from the MATLAB help file on `unique`:

[C <http://se.mathworks.com/help/matlab/ref/unique.html#outputarg_C>,ia 
<http://se.mathworks.com/help/matlab/ref/unique.html#outputarg_ia>,ic 
<http://se.mathworks.com/help/matlab/ref/unique.html#outputarg_ic>] = 
unique(A <http://se.mathworks.com/help/matlab/ref/unique.html#inputarg_A>) also 
returns index vectors ia and ic.

   - 
   
   If A is a vector, then C = A(ia) and A = C(ic).
   - 
   
   If A is a matrix or array, then C = A(ia) and A(:) = C(ic).
   - 
   
   If A is a table, then C = A(ia,:) and A = C(ic,:).
   

Which of the cases is relevant for you?

// T

On Tuesday, April 21, 2015 at 11:16:12 AM UTC+2, Stephan Buchert wrote:
>
> In Matlab I can do, for example, with "daynum" fractional day numbers:
>
> idaynum = floor(daynum);
> [umjd, im, iu] = unique(idaynum);  % <= how do I get the "iu" in Julia?
>
> % I need an observation "pms" listed per day in a file.
> % For performance reasons the parameter is retrieved from the file only 
> once for each of the different integer days
> upms = pi*umjd;   % <= for illustration only, instead of really 
> retrieving the observed parameter
> pms = upms(iu);
> % Now "pms" matches "daynum", ie. when daynum=[1.0, 1.5, 1.8, 2.0, 2.2, 
> 3.1], then pms approx. [3.14, 3.14, 3.14, 6.28, 6.28, 9.42]
>
> Probably this can be done elegantly also in Julia, but, coming from 
> Matlab, for me not easy to see how?
>

Reply via email to