I'm converting the simulink diagram found in this paper to C code. I'm not familiar with matlab/simulink(too expensive) so need help interpreting the diagram. The problem I experience is that once a value like $\theta$, or $x_1$ becomes zero, zero is propagated everywhere due to the multiplication. The paper states that the integrators are initialized to zero, so I don't see how the system works.

Any ideas?

Below is the simulink diagram and my C code:

The block diagram is found in the paper above as Figure 1 and Figure 2 :

Thank, Peter, for pointing out that error. My problem now is I don't understand how those integrator boxes work. The main integrator seems to be turning the derivative of theta into the new theta, as only theta appears in the diagram. Does just keeping a running sum of the derivatives form the derivative? Thus: anf->s.theta += -anf->p.gamma * anf->s.x1 * anf->s.theta * anf->s.err;
–
Chuck CarlsonFeb 26 '13 at 14:54

Could it be that the left side is not the derivative but a correction factor?
–
Chuck CarlsonFeb 26 '13 at 15:11