Guessing values in real time based on previous values

213 views Asked by At

smoothing values

The following applies to c# .net 4. I am looking for a c# code.

(Figure 1) I have different values, for instance 700, 712, 703 and 720. dt1 is for instance 30ms, dt2 may be 9ms. What matters is that dt1 to dtn is not constant.

(Figure 2) The time axis

(Figure 3) This is what I want, values for a constant time gap tc of roughly 17ms. x1 to xn are the values a variable consists of, ie:

x(t(x1)) = x1
x(t(x2)) = x2
...
x(t(xn)) = xn

How do I determine x1 to xn in real time? So let's say the current time is dt1+dt2+somewhere within dt3. I do not know when dt3 will be finished(even though previous dt were in between 9ms and 30ms) and what value there will be. How could I guess a value for x4 that takes previous changes into account?

How do I smooth the values of (Figure 1) at the same time for them to be - say - 700 - 708 - 712 - 720, ie remove the jitter?

2

There are 2 answers

2
Alex On

Gonna take a shot at this (poorly worded sequence of operations following):

  1. read current X (let's call it Xt)
  2. perform whatever operation you need with Xt
  3. store Xt
  4. read new X (let's call it X2)
  5. if abs(X1-X2) is less than a certain tolerance, discard X2 and make it = X1

    if X2 > X1, discard the value of X2 and make it = X1+K

    if X2 < X1, discard the value of X2 and make it = X1-K

  6. set Xt = X2

  7. goto 2

Just a very rough idea of "smoothing" where you ignore the value and only care for the orientation of the "movement" of your x.

1
Mohammad Ahmad Abdullah On

I think There Are Two Solutions As I Understood Your Questions

  1. Pass Variables by reference e.g : x(ref t(ref (x1))
  2. declare Your Variables as static variable e.g : static x1