Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Using piecewiseconstant functions in ode Simulink
Posted:
Feb 23, 2013 9:37 PM


Hi,
I want to integrate the multiplication of a cosine with a piecewiseconstant function (e.g. 1 from 0 to 1/1000, 1 from 1/1000 to 2/1000, ...)
The time axis is equally distributed among the time (i.e., transient change 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 greatly appreciated!!
What I did was (among other tries): Create a pulse block with rising edge every 1/1000 which triggers a "Triggered Subsystem". This calls a MATLAB function which uses find_system/set_param to change the value of a constant block. This constant is then multiplied by the cosine and followed by an integrator.
However, this seems to work for some signal but for some it introduces huge errors.
For example
p = 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 block
y at t=3/1000 should be 8.00487e4 if I solve analytically but Simulink has 8.29766161000261e4 :( :(
Thanks a lot! Peter



