Jump to content
Sign in to follow this  
Jsmidlow

Min values from unknown number of arrays

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×