There are many times when I need to grab the last element or last n elements of an array. This usually involves a call to Array Size and then a subtraction, costing me time and block diagram clutter. Array reversal is essentially free, but again costs clutter and clicks. For common array types I have personal VIs to do the job, but that is just a band-aid with the proliferation of data types that I use. My idea would be to treat negative values input to the index array or array subset VIs (for example) as counting from the end of the array. The last value would have index -1 and so on. To get the last n values I would put -n into the Array subset VI and that's it. For expanding the Array Index VI, my preference would be that it counts down (-2,-3,-4,...).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.