03-11-2015 11:21 AM
Im frustrated at myself because this seems like it would be very simple and I'm stuck.
I have a 1D array of values. Id like to calculate the average rate of change for every set of 11 elements. I've already calculated by hand what im expecting and everything ive tried in labview is not matching up, I've tried the derivative function and shift registers. Maybe I'm just using the shift registers wrong, as I'm pretty new with using them.
Could anyone offer some advice or examples? Much appreciated, as always.
Solved! Go to Solution.
03-11-2015 11:24 AM
Rate of change within those 11 samples, or rate of change between groups of 11 samples?
03-11-2015 11:28 AM
Within
03-11-2015 11:32 AM
By average rate of change, do you simply mean [(last element) - (first element)] / 11 ? Or am I missing something?
03-11-2015 11:36 AM
Maybe try something like this. Split the array into 11 element arrays and put those into a linear fit vi. One of the outputs is the slope.
You may need to create an x array to the input, I'm not quite certain, but this should have some key elements you could use.
03-11-2015 11:58 AM
no, I want (element2-element1) (element3-element2) (element4-element3) and so on until element 11, then divided by eleven, and then go through the whole cycle again so (element13-element12)(element14-13) and so on until element 22, divide by eleven, then again, and again...
03-11-2015 12:19 PM
@libbyherself wrote:
no, I want (element2-element1) (element3-element2) (element4-element3) and so on until element 11, then divided by eleven, and then go through the whole cycle again so (element13-element12)(element14-13) and so on until element 22, divide by eleven, then again, and again...
I think you need to divide by 10, because with 11 elements, you only have 10 differences.
03-11-2015 12:26 PM - edited 03-11-2015 12:26 PM
03-11-2015 12:34 PM
Thanks this worked perfectly. Turns out some of my "expected" values calculated were wrong which threw me off... It's always the silly mistakes that get me. But this solution is actually more simple than what I had so thank you.
03-11-2015 12:47 PM
@libbyherself wrote:
no, I want (element2-element1) (element3-element2) (element4-element3) and so on until element 11, then divided by eleven, and then go through the whole cycle again so (element13-element12)(element14-13) and so on until element 22, divide by eleven, then again, and again...
Expand your math out and you can make this a lot simpler.
[(B-A) + (C-B) + (D-C) + (E-D)]/4 = (E-A)/4
So you really could to the difference between the first and last elements and divide by the number of changes.