hotbuttmud Posted June 9, 2011 Posted June 9, 2011 (edited) I am trying to set up a Proportional, Integral, Derivative program, and I need some help on derivative filtering. I want to add values to the end of an array until there are 20 elements total. From there, I want to use Array Push to keep the last 20 values. Any advise? One other is, is there a short way to find the average value of those 20 values? Edited June 9, 2011 by hotbuttmud
hannes08 Posted June 9, 2011 Posted June 9, 2011 Hi hotbuttmud, well, use _ArrayPush() then. Define a new array with 20 items (dim $array[20]) and then use _ArrayPush(). Example: #include <array.au3> Dim $a[20] For $i = 0 To 30 _ArrayPush($a, $i) ConsoleWrite(_ArrayToString($a) & @CRLF) Next Getting the average out of that array: $k = 0 For $j = 0 To 19 $k += $a[$i] Next ConsoleWrite("Average:" & %k / 20) Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now