# Parameter Estimation for First Order System

I would like to get a simple estimation of the parameters for a humidity chamber system. The humidity chamber has one constant inflow ($k_1$) and and outflow which depends on the humidity of a neighbor humidity chamber (diffusion, modeled as $k_2(RH_{ext} - RH)$. $RH$ is the humidity of the chamber, $RH_{ext}$ is the humidity of the external chamber. I have the following system description (first order): $$\frac{dRH}{dt} = k_1 + k_2(RH_{ext} - RH)$$

Now, I have measurement data for $RH$ (output) and $RH_{ext}$ (input). $k_1$ could be seen as a second (constant) input. I would like to estimate the parameters $k_1$ and $k_2$ in a simple manner (maybe least-square based) using my (discrete) measurement data in Matlab, but I don't know how I could proceed. Use the system identification toolbox? Other ways?

• Hi Fabian, welcome to engineering.SE. Our site supports Latex style equation typesetting; I've edited your post to use it. Jun 9 '15 at 12:30
• What type of measurement data do you have? Is it $RH$ vs. time with all other parameters constant? If so, you can simply integrate the equation and do a 3 parameter curve fit ($k_1$, $k_2$, and the integration constant). Jun 9 '15 at 12:33
• Hi Chris, thanks very much for the edit and your answer. $RH_{ext}$ isn't a constant as well. Your approach seems clever, but I'm not so sure about how to do this in practice. You would simply try to fit $RH(t)$ to $f(t)=k_1 t + k2\left(\int RH_{ext} - \int RH \right)+c$, by using the numerical integrations $\int RH_{ext}$ and $\int RH$ ? Jun 9 '15 at 13:02

It sounds like you have MATLAB, so it's a simple linear fit:

• From your vector $RH(t)$, compute $\frac{d RH}{dt}$ by numerical differentiation
• Create a matrix $A$ with ones on the first column and the values of $RH_{ext}(t) - RH(t)$ on the second column
• Create a matrix $B$ with the values of $\frac{d RH}{dt}$ (use 0 as the initial value)
• Your result vector is given $A$ \ $B$

dRH = [0; diff(RH)./diff(t)];

A = [ones(size(RH)) RH_ext-RH];

k = A\dRH; % k(1) is k1, k(2) is k2

• Just to emphasize the point; $A\setminus B$ uses Matlab's left division operator which is used to solve a system of linear equations described in matrix notation. Jun 9 '15 at 16:56
• @ChrisMueller yes, that's right. Thanks for the clarification Jun 9 '15 at 17:16