most likely Kcos(wt + a) is your switching function.
in MATLAB script, or any other programming tools you can implement this nonlinear set of equation. use basic concept of discreet integral and derivative. for example you can define dt = 0.0001 and multiply of divide it in each iteration.
I have solved the same set of equation in MATLAB/script.