I have implemented the closed-loop motor control system as above in a Matlab simulation (pic Kalman.png). Here, the Kalman filter estimates the torque disturbance and angular speed of the motor and those are feed to the RLS algorithm for parameter identification, here it estimates the combined inertia of the rotor and the load. I have successfully simulated it with a constant J feed to the Kalman filter (0.089 for example) instead of feeding estimated J back to the Kalman filter in pic (Kalman1.png), and the RLS parameter identification correctly estimates the inertia which is close to 0.089 (within 0~3% error band). But, when I feed the RLS estimated J to back to the Kalman filter after running for few seconds when the J estimate reaches close to 0.089, using an analog switch, the system becomes unstable and RLS outputs become 'nan'. I tried using an average block (avg of 100 samples) between the RLS and Kalman filter in the J feedback line and it seems to stabilize the system a bit but not for a long time. I guess there is a better way to achieve the following: 1) Removing the average block 2) The J (estimated) connection between the RLS and the Kalman filter should be there from the beginning without the need of an analog switch. My control engineering knowledge is not advanced level so any suggestion of an idea, document or a book (application oriented) will be highly appreciated.