04-17-2012 07:59 AM
I have two 1D arrays that contain cyclical information (kind of like a sine wave). One that contains information on position in degrees and another that contains torque. I would like to calculate the maximum torque value each time the position is within a certain range (e.g. from 30-80 degrees). The ranges are repeated - that's why it is cyclical. I use the "in range" function, a case structure and shift registers to build a new array with values that fall within the range I specify - this was the easy part (see VI attached). I'm struggling with a way to calculate a maximum value for each subarray formed when values are "in range". Your help is much appreciated.
Solved! Go to Solution.
04-17-2012 08:28 AM
One way would be to keep track of the array indices when coming in/out of range. Then, look at each one of those subsets and find the max value.
04-17-2012 08:30 AM
Something like this: (Though, I'm sure there is a more elegant way)
04-17-2012 08:45 AM
I thought of that and can easily create another array with indicies that fall within range. However, I could only generate a list of indicies and I'm not sure where they should start and stop to use in an index array or array subset. I might be able to figure it out if I knew when the case was true the first time it was in range.
04-17-2012 08:59 AM
I just got your last post - I'll check it and see if it work. Thanks a bunch.
04-17-2012 09:18 AM
Is the position array really this regular? You then could just reshape the torque array into a 2D array, one cycle per row and then autoindex, taking the subset max for each iteration.
04-17-2012 09:25 AM
Unfortunately, it's really not that regular where I could rely on it with confidence.
04-17-2012 09:49 AM
vt92's solution worked! I agree that there should be a simpler solution, but your's works just fine. Many thanks.
04-17-2012 09:52 AM
Then please attach more typical data. Is there noise in the real position?
04-17-2012 09:59 AM
It's not really noise - it's more inconsistency. So a position output can run: 20, 30, 40, 50, 60 etc. OR, it could run: 21, 24, 32, 41, 44, 51, 59 etc. But, it is always cyclical.
Attached you will find a .csv file with the data arrays - I'm using POS (ANAT) degrees column (column D if you open in excel). There you also see torque in ft-lbs along with some other information.