Jump to content

Min values from unknown number of arrays


Jsmidlow

Recommended Posts

Hello. I have an array attribute and I need to figure out min values among all first, second, third, etc elements of arrays. If I were about to know the exact length of array (let's say 3) I would do this... iterate insider forloop "distancesappend values to three new arrays and find min values with min function. min(distancesone[0]), min(distancestwo[1]), min(distancesthree[2])...... My problem is that I don't know the exact number of array and min() is useless as long as I can't manually create arrays of specific number elements. So the question is how can I figure put the min value among distances[0] elements, then [1], [2] and so on... 
Thank you.  

Снимок.PNG

Edited by Jsmidlow
Link to comment
Share on other sites

for( int i = 0; i<detail(0, 'arrlen', 0); i++ )
{
    float arr[];
    for( int j =0; j<npoints(0); j++ )
    {
        float arr_val[] = point(0, 'distances', j);
        if (len(arr_val)>i)
            append(arr, arr_val[i]);
    }
    append(f[]@mins, min(arr));
}

 

Like this? In a detail wrangle you'd get a detail array attribute where each element is the smallest value at that index of 'distances'. You can get the length of longest array with attrib promote beforehand.

Edit: code quote thing was weird

Edited by Dweeble
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...