Tag Info

New answers tagged

0

In Mathematica, given a list of datapoints $\mathbf{f}$ whose spatial axis has separation $\Delta$ (or whose temporal axis has time-step $\tau$), $\mathbf{\tilde{f}}=\text{Fourier}[\mathbf{f}]$ is a list of datapoints whose $j^\text{th}$ datapoint corresponds to angular spatial frequency $$k_j=\frac{2\pi(j-1)}{N\Delta}.$$ So for example, the first element ...


10

Since you are using this as an excuse to learn to code in Mathematica, I'll try to help with that in mind. Sometimes I find it nice to design "from the top down", document from the top down, split in many small functions with no state, and go testing them "from the bottom up". As you gain confidence, you will perhaps use coarser functions, and not test every ...


5

Want to plot a region defined by an inequality? Just use RegionPlot. z = x + I y; p1 = 1 + z; p2 = 1 + z + 1/2 z^2; RegionPlot[{Abs[p1] <= 1, Abs[p2] <= 1}, {x, -2.5, 0.5}, {y, -2, 2}, AspectRatio -> Automatic] If you just want the boundary contours, use ContourPlot[{Abs[p1] == 1, Abs[p2] == 1}, ... instead. Oh hey check it out: p[z_, n_] ...


2

This is just a long supplement comment to @James Cunnane's answer which is correct. Try dt = 1/100; T=Pi; ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, T, dt}]; ListPlot[ls, Mesh -> All, MeshStyle -> Red] ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, DataRange -> {0, 1/dt}, FrameLabel -> {"Frequency", "Intensity"}, Mesh -> ...


2

A windowing function should help: ls2 = (ls - Mean[ls]) Array[TukeyWindow, Length@ls, {{-0.5, 0.5}}]; ListLinePlot[ls2] ListLinePlot[Abs[Fourier[ls2]]^2, PlotRange -> {{0, 10}, {0, 1}}, DataRange -> {0, 1/dt}, FrameLabel -> {"Frequency", "Intensity"}, Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]


3

This comes from the jump disontinuity of two argument ArcTan. My solution can be automated, but I'll leave that to you for the time being. My strategy is to find where the discontinuity is, then lift the right part of the graph up by a constant. The jump of two argument ArcTan occurs when $x < 0$ and $y = 0$: Plot3D[ArcTan[x, y], {x, -π, π}, {y, -π, ...


3

Please tell me if this produces what you expect: link[a : {{_, _} ..}, b : {{_, _} ..}] := Join[a, (b\[Transpose] - First[b] + Last[a])\[Transpose]] link[x__] := Fold[link, {x}] gp1fix = gp1 /. Line[x_] :> Line[link @@ Split[x, EuclideanDistance[##] < 1 &]]; Show[gp1fix, gp2, Axes -> False, Frame -> True, FrameStyle -> ...


7

I believe the frequency mismatch arises because the endpoints of your 200 point series are offset. The first point has amplitude 0.1, the last 1.5584. As others mention, the Fourier transform assumes periodicity. So the signal you are transforming has a sine component, a cosine component, and a step function offset of the first and last points. The Fourier ...


7

Fourier Transform is based on assumptions of periodicity related to the duration of the data. If you choose a misleading duration, you will get misleading results. The duration (200 dt) of your array ls is not a multiple of the periods of your waveforms; this introduces artefacts arising from the Fourier transform of the 'top hat' function of width (200 ...



Top 50 recent answers are included