2
$\begingroup$

Yesterday, I tried to find constants $k_1$ and $k_2$ for the following system:

$$\frac{\mathrm d RH}{\mathrm dt}=k_1+k_2(RH_{ext}-RH).$$

Now, I have some first computations for $k_1$ and $k_2$ and would like to test how good a simulation with these parameters works. I think I could also write this as state space model:

$$\dot{x}=-k_2x+\left[\begin{matrix} k_1 & k_2\end{matrix}\right]\left[ \begin{matrix} u_1 \\ u_2\end{matrix} \right],$$

$$y = x,$$

where $x = RH$, $u_1=1$ ($const.$) and $u_2=RH_{ext}$. I have measurement data for $RH_{ext}$ in Matlab (vector), a time vector $t$ with the same length and would like to do a simulation for $RH$.

Any suggestions how I could proceed? Simulink is possible, but just a script-based solution would be even better.

$\endgroup$
  • $\begingroup$ I like "R" because while it is (slightly) klugy, it is free, and it has a stunningly wider variety of toolboxes, called libraries, that are also free. You can make and sell products day 1, without paying thousands of dollars per seat per year for a professional license. Can I give you an "R" friendly answer? Also - my experience with engineering curriculum is that they (sadly) teach you to focus on the mean, and not balance the central tendency with tendency of variation. What does it mean if your parameters are not infinitely precise? :) $\endgroup$ – EngrStudent Jun 10 '15 at 12:24
  • 1
    $\begingroup$ Shouldn't there be a plus sign in front of $[k1\; k2]$ instead of the minus sign? $\endgroup$ – fibonatic Jun 10 '15 at 15:09
1
$\begingroup$

Yes, if you have values for k1 and k2, data for RH_ext and t, your suggestion would work although I think you have your matrices wrong. You probably need to define x as RH - k1/k2 to get rid of the constant term:

A = -k2;
B = k2; % x_dot = -k2*x + k2*u
C = 1;
D = 0; % y = x
sys = ss(A,B,C,D);
y = lsim(sys,RH_ext,t);
RH_sim = y + k1/k2;
$\endgroup$
  • $\begingroup$ I think lsim was the kind of function I was looking for, thanks! Why should I choose $B=k_1+k_2$? I mean only $k_2$ should act on the input $RH_{ext}$. My problem is basically what to do with the constant $k_1$ . $\endgroup$ – donald Jun 11 '15 at 6:35
  • $\begingroup$ Oops, you're right. I will edit my answer. $\endgroup$ – am304 Jun 11 '15 at 6:41
  • $\begingroup$ Introducing $x$ makes sense, excellent! $\endgroup$ – donald Jun 11 '15 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.