I have since found a workaround for my own problem, so I'm posting it here for the benefit of others. I gave up on trying to use a Trapezoidal integration approach and reverted to the Forward Euler method since it has no direct feedthrough of the input. The code is shown below:
function y_k = fcn(u_k, Ts)
persistent x_k1 initial_condition step_zero
if isempty(x_k1), x_k1 = 0; end
if isempty(initial_condition), initial_condition = 0; end
if isempty(step_zero), step_zero = 1; end
K = 1;
x_k = x_k1;
if(step_zero == 1)
y_k = initial_condition;
x_k1 = y_k + K*Ts*u_k;
step_zero = 0;
else
y_k = x_k;
x_k1 = x_k + K*Ts*u_k;
end
if(x_k1 > 2*pi)
initial_condition = x_k1 - 2*pi;
step_zero = 1;
end
This code is equivalent in function to the pictured Simulink blocks.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/357313/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/357313/image.png)
Finally, double click the function block to open the Function Editor, in the Simulink Pane at the top, select Edit Data, then uncheck Allow Direct Feedthrough.