# How do I compute the feedforward terms in a control law using Matlab?

I have the following situation. I have computed the linear and angular velocity which are the controls for a mobile robot, which have the form:

$$v_d=v_{fb}+v_{ff}$$

$$\omega_d=\omega_{fb}+\omega_{ff}$$

now, I would like to define the acceleration controls, and I know that I can do it in the following way:

$$a_v=(v_d-v_{actual})+\dot{v_d}$$

$$a_\omega=(\omega_d-\omega_{actual})+\dot{\omega_d}$$

I would like to do this using Matlab\Simulink. This code is inside a Matlab function clock.

my question is:

Is there a way I can compute the feedforward terms $$\dot{v_d}$$ and $$\dot{\omega_d}$$ without computing them manually?

I would like to avoid to compute them manually since their expression is really complicated and it is almost impossible to not make mistakes.

How are you calculating $$v_d$$ and $$\omega_d$$? Simulink has a derivative block, have you tried using that?