I want to insert the below function K, in my simulink model, to calculate the dynamic transmission error (dte).
The problem is the function K depend on Θp. I don't know if there is any way to do that in simulink.
I would appreciate any suggest.
/note: Answer has been rewritten completely.
You can't use a gain block. Any parameter like "Gain" is only evaluated once at the start of the simulation. If you have something which changes over time like your Θp you have to use the signal.
In your case having a one line MATLAB expression to evaluate, the easiest way to use it is a "Function Block" (User-Defined Functons->Fcn), not a MATLAB Function as I originally suggested. Replace the MATLAB Function you already got in your code with a Function Block and use the code:
a0 + sum( af .* cos(n * zp * u) + bf .* sin(n * zp * u) )
The nice advantage is, that all workspace variables are already initialized.
I applied some modifications to the formula, using element-wise multiplication where I expect it should be used. You can use the same code line in MATLAB to verify it really does what you expect.