I am trying to simulate a signal that randomly increases its phase, so far I have tried two thing but neither worked. I usually use matlab but I want to learn some Mathematica so I thought I would try this in Mathematica.
My first try was
times = Table[i, {i, 0, 2, 0.05}];
function[source_, t_][fiIN_] :=
With[{fi = fiIN + 0.01*RandomReal[]},source*(1 + Sin[2 Pi*t + fi])];
Where I wanted to feed fi
back into fiIN
for each subsequent t
value (in the list times
). I did not know how to makes this work though so I went on with my second try:
fiupdate[fi_] := fiupdate[fi - 1] + 0.01*RandomReal[];
fiupdate[1] = 0;
fitimes = Range[Length[times]];
However this function does not remember the value of RandomReal[]
for the earlier steps, so fiupdate[10]
could be smaller than [9]
or [8]
. Also when using this function I get an error:
fis = fiupdate[fitimes];
$RecursionLimit::reclim: Recursion depth of 1024 exceeded
Im not sure how to make this work. Any help is appreciated. Thank you!