```Date: Feb 23, 2013 9:37 PM
Author: Peter Mairhofer
Subject: Using piecewise-constant functions in ode Simulink

Hi,I want to integrate the multiplication of a cosine with apiecewise-constant function (e.g. 1 from 0 to 1/1000, -1 from 1/1000 to2/1000, ...)The time axis is equally distributed among the time (i.e., transientchange every 1/1000) and the values are stored in an array in MATLAB.I'm struggling arround for 2 days on this issue :( So help is greatlyappreciated!!What I did was (among other tries): Create a pulse block with risingedge every 1/1000 which triggers a "Triggered Subsystem". This calls aMATLAB function which uses find_system/set_param to change the value ofa constant block. This constant is then multiplied by the cosine andfollowed by an integrator.However, this seems to work for some signal but for some it introduceshuge errors.For examplep = 1 for [0,1/1000], -1 for [1/1000,2/1000] and 1 for [2/1000,3/1000]x = cos(100*pi*t);y = (p*x)-> 1/s blocky at t=3/1000 should be 8.00487e-4 if I solve analytically but Simulinkhas 8.29766161000261e-4 :( :(Thanks a lot!Peter
```