Skip to main content
added 110 characters in body
Source Link
xslittlegrass
  • 27.8k
  • 9
  • 102
  • 187

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using Mathematica's signal processing features?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Edit

I'm still not convinced that this problem is due to that there are too few periods contains in the signal, nor that number of periods contained in the signal is not an integer. Consider this signal

ls = Table[0.1 Cos[30 x], {x, 0, 200 dt, dt}];

it contains the same number of periods, and the number of periods is not an integer, it gives a peak that are not centered,

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

but padding zero helps

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using Mathematica's signal processing features?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Edit

I'm still not convinced that this problem is due to that there are too few periods contains in the signal. Consider this signal

ls = Table[0.1 Cos[30 x], {x, 0, 200 dt, dt}];

it contains the same number of periods, and it gives a peak that are not centered,

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

but padding zero helps

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using Mathematica's signal processing features?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Edit

I'm still not convinced that this problem is due to that there are too few periods contains in the signal, nor that number of periods contained in the signal is not an integer. Consider this signal

ls = Table[0.1 Cos[30 x], {x, 0, 200 dt, dt}];

it contains the same number of periods and the number of periods is not an integer, it gives a peak that are not centered,

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

but padding zero helps

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

added 904 characters in body
Source Link
xslittlegrass
  • 27.8k
  • 9
  • 102
  • 187

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using Mathematica's signal processing features?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(eV2 π)"}, "FourierNone}]

enter image description here

Edit

I'm still not convinced that this problem is due to that there are too few periods contains in the signal. Consider this signal

ls transform= (arbTable[0.1 Cos[30 x], {x, 0, 200 dt, dt}];

it contains the same number of periods, and it gives a peak that are not centered,

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)"}, None}]

enter image description here

but padding zero helps

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description hereenter image description here

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using Mathematica's signal processing features?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency (eV)", "Fourier transform (arb.)"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using Mathematica's signal processing features?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Edit

I'm still not convinced that this problem is due to that there are too few periods contains in the signal. Consider this signal

ls = Table[0.1 Cos[30 x], {x, 0, 200 dt, dt}];

it contains the same number of periods, and it gives a peak that are not centered,

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

but padding zero helps

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

added 23 characters in body
Source Link
xslittlegrass
  • 27.8k
  • 9
  • 102
  • 187

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using Mathematica's signal processing features?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency (eV)", "Fourier transform (arb.)"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using signal processing?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency (eV)", "Fourier transform (arb.)"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

I have a signal that I want to identify the frequencies in it, I used the Fourier function but I can't get the frequency correctly. Here is a simplified example:

dt = 1/100;
ls = Table[0.1 Cos[30 x] + 2 Sin[x]^2, {x, 0, 200 dt, dt}];
ListPlot[ls, Mesh -> All, MeshStyle -> Red]

enter image description here

and the Fourier transform

ListPlot[Abs[Fourier[ls]]^2, PlotRange -> {{0, 10}, {0, 1}}, 
 DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency", "Intensity"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Why do I get the peak not at the original frequency 30/(2Pi), but with a frequency shift? Did I make a terrible mistake? What's the correct way to recover the original frequency using Mathematica's signal processing features?

I tried to padding zeros but still have a frequency shift.

ListPlot[Abs[Fourier[PadRight[ls, 2000]]]^2, 
 PlotRange -> {{0, 10}, {0, .1}}, DataRange -> {0, 1/dt}, 
 FrameLabel -> {"Frequency (eV)", "Fourier transform (arb.)"}, 
 Mesh -> All, MeshStyle -> Red, GridLines -> {{30/(2 π)}, None}]

enter image description here

Source Link
xslittlegrass
  • 27.8k
  • 9
  • 102
  • 187
Loading