I am trying to model a gear with a gear tooth defect in the MATLAB/Simulink Simscape-environment. A tooth defect appears as an momentarily loss in gear meshing stiffness, which can be implemented in the model by modeling a square wave signal with a decrease of the signal value at the instant when the defect tooth meshes with a tooth on the opposing gear. The loss in meshing stiffness is present at every revolution of the gear. So, for a gear with five teeth and a defect at one of the teeth, every fifth mesh will appear as a loss in meshing stiffness, and thus, a decrease in the square wave signal.
The square wave signal has a maxima at the maximum meshing stiffness, $k_{max}$, and a minima at the minimum meshing stiffness, $k_{min}$. At the defect, both $k_{max}$ and $k_{min}$ gets subtracted by $\Delta k_{loss}$. The frequency of the function is obtained by multiplying the angular velocity $\omega$ of the gear by the number of teeth $N$, so that $f=\omega N$. The function I am trying to find is shown graphically in this figure.
This can be done in MATLAB by using two square functions with different duty cycles as follows,
A*square(f*t, 50) - A_flt*square(f*t/N, 100/N) + z;
where
$$A = \frac{k_{max}-k_{min}}{2}$$
$$A_{flt}= \frac{\Delta k_{loss}}{2}$$
$$z = A - A_{flt} + k_{min}$$
However, by using Simscape as the modeling environment, I am not allowed to use MATLAB functions directly. Thus, I have to do this purely by math. The square wave signal, without meshing losses, can be made by using a signed sine function, given as,
$$A*sgn(sin(ft))+z$$
where
$$z = A + k_{min}$$
I figure that subtracting the function by another periodic function with different duty cycle as in the MATLAB code, or making $z$ a periodic function that decreases by $\Delta k_{loss}$at every $n^{th}$ period and stays constant for the rest of the time, would leave me with my desired function. However, I can't seem to figure out how this can be done. Does anyone know a good approach to this problem?
