Jsmidlow Posted July 19, 2021 Share Posted July 19, 2021 (edited) 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 "distances" append 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. Edited July 19, 2021 by Jsmidlow Quote Link to comment Share on other sites More sharing options...
Dweeble Posted July 19, 2021 Share Posted July 19, 2021 (edited) 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 July 19, 2021 by Dweeble Quote Link to comment Share on other sites More sharing options...
Jsmidlow Posted August 4, 2021 Author Share Posted August 4, 2021 Thank you) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.