# Difference equation system identification

Suppose I have a difference equation modeling a vehicle like this:

$$d[k+1]=d[k]+a\cdot u[k]+b,\tag1\label{eq}$$

where $$d[k]$$ is total distance traveled at time $$k$$, $$u[k]$$ is engine input at time $$k$$ (e.g. some measure of engine exertion at that time, not really important exactly what it is), and $$a, b$$ are parameters that I want to estimate from data points that I measure, for example by least squares.

From the difference equation I see that the units of $$a\cdot u[k]$$ and $$b$$ need to be distance. But suppose that the data I gather are actually samples of the vehicle's velocity (not position) for some range of input values, so I can plot velocity vs. engine input.

My question: I'm confused because it seems that it wouldn't make sense to do least squares regression to fit $$a\cdot u[k]+b$$ to these points since that would violate the units, but that is what is done in an example in my course. After the parameters are determined, the example then uses those same parameters to model the distance traveled over time via $$\eqref{eq}$$, going off of some initial starting distance $$d[0]$$. Am I missing something in this example?

• I don't get your point about units. Why would that be a "violation of units"; why does the unit matter? Whether I minimize X in "mm", "km", "horsepowers" or "thrown cats squared per fiscal year" doesn't matter. Commented Sep 13, 2020 at 9:44
• @MarcusMüller I don't understand why the units wouldn't matter? If I had a graph of thrown cats vs. engine exertion and did regression to find a line of best fit $cats[k] = a*u[k]+b$, wouldn't it be complete nonsense to then expect those same parameters to model the distance traveled, as in the original difference equation? Commented Sep 13, 2020 at 17:30

## 1 Answer

Note that for a small sampling interval $$T$$, $$\big(d[k+1]-d[k]\big)/T$$ is a good approximation for the velocity. So if you fit $$au[k]+b$$ to a given set of measurements $$v[k]$$, it is valid to conclude

$$d[k+1]=d[k]+T\big(au[k]+b\big)\tag{1}$$

In the text you refer to they might have normalized $$T$$, so it changes the units without changing the values of $$a$$ and $$b$$.

• Thanks very much for the help. The text doesn't refer to the sampling period at all which is a bit confusing but this explanation makes sense to me. So am I right then to be in general concerned with whether the units of the expression I'm doing regression on are consistent with the expression's later use in (1), which another commenter here objects to? Commented Sep 13, 2020 at 15:09
• @knzy: With discrete-time signals I wouldn't generally worry too much about units. It usually gives more trouble than illumination. Commented Sep 13, 2020 at 18:53