Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*declaration of parameters*)
- T = 2.0;
- w = 0.05;
- a = 2.0;
- num = 1000.0;
- A = 1.0;
- Amp = 0.05;(*noise amplitude*)
- (*declaration of continous function*)
- pulse[x_] := A*(UnitStep[x + w*T] - UnitStep[x - w*T])
- (*funciton sampling*)
- funX = Table[i, {i, -T/2, T/2, T/(num - 1)}];
- fun1 = pulse /@ funX + Amp*RandomReal[{-0.5, 0.5}, num];
- fun2 = pulse /@ (a*funX) + Amp*RandomReal[{-0.5, 0.5}, num];
- ListPlot[Transpose[{funX, fun1}], PlotRange -> All, Filling -> Axis,
- Frame -> True, FrameLabel -> {"Time [s]", "Amplitude [V]", "Pulse"},
- PlotLegends -> {"Pulse"}, ImageSize -> Large]
- (*Fourier Transform*)
- xf = With[{
- i = Function[{t0, t1, x0, x1},
- Evaluate@
- Integrate[(x0 + (x1 - x0)/(t1 - t0) *(t - t0))*
- Exp[-2*Pi*I*f*t], {t, t0, t1}]]},
- Compile[{{f, _Real}, {t, _Real, 1}, {x, _Real, 1}} ,
- Total@i[Most[t], Rest[t], Most[x], Rest[x]]]
- ];
- freq = Table[j, {j, -40., 40.}]/T;
- Xorig = xf[#, funX, fun1] & /@ freq;
- Xscaled = xf[#, funX, fun2] & /@ freq;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement