help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] ODE for state space system


From: toso
Subject: [Help-gsl] ODE for state space system
Date: Wed, 12 Apr 2006 16:55:30 +0200

Hi all, I'm writing a code to compute the time response of a mechanical system written in a state space form
dot(x) = A x + B u
y = C x + D u I use for the first system of equation the gsl rk4 ode solver and an then I evaluate the system outputs (y). The problem arise when I compare the results with matlab (same system, same solver). I have tried two different ways t calculate y. The pseudo code that I use is: /* evaluate state evolution and then calculate outputs */
while( t < t_end )
{
  u = new_inputs();
  gsl_odeiv_step_apply( .. );
  update_state_derivatives( .. );
  y = C x + D u;
  t += dt;
}
/* calculate outputs and then evaluate state evolution*/
while( t < t_end )
{
  u = new_inputs();
  y = C x + D u;
  gsl_odeiv_step_apply( .. );
  update_state_derivatives( .. );
  t += dt;
} I thought the second way was corrected but it gives worse results with respect to the first one. The example that I've tried has 4 states with natural frequencies 4 and 50 Hz, the input is a chirp signal between 0.1 and 100 Hz, and if I sample it at 512 Hz the error is more than 40% while using 2048 Hz decrease to 4% but I think it's still a lot. Do anyone has any idea? Alessandro Toso




reply via email to

[Prev in Thread] Current Thread [Next in Thread]