Tag Info

New answers tagged

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_] ...


1

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}]


2

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 ...


6

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 ...


0

Fit is a function that finds the linear combination of some given terms that best fits the data. This can also be used since sine Fourier series are linear combinations of Sin. len = Subtract @@ data[[{-1, 1}, 1]]; func = Fit[ data, Table[ Sin[(π n)/len x], {n, 1, 40}], x ] Show[ ListPlot[data], Plot[func, {x, 0, len}, PlotStyle -> {{Thick, ...


2

I took george2079's statement "Now I expect someone will show a built-in way to get this..." as a challenge, so I did the same thing using FindFit. Also, writing it this way seems more clear to me what the actual function being fitted is (but obviously relying on the internal FindFit function) len = (Max[#] - Min[#]) &@data[[All, 1]]; func = ...


4

I've done this from first principles: some random data: data = Table[{x + RandomReal[{-.05, .05}] + 4, Sin[x] + Sin[x/3] + RandomReal[{-.3, .3}]}, {x, 0, 12 Pi , .1}]; treat the discrete data as a function and and use trapezoidal integration: trule = Mean /@ Partition[ Differences@ {data[[1, 1]], ...



Top 50 recent answers are included