Message Boards Message Boards

Sorting Data

Posted 10 years ago
I have a Discrete Fourier Transform of some data that I was given:

 v = {0.000549316, 0.000518799, 0.000518799, 0.000549316, 0.000549316,
   0.000579834, 0.000610352, 0.000640869, 0.000701904, 0.000793457,
   0.000793457, 0.000793457, 0.000732422, 0.000732422, 0.000762939,
   0.000701904, 0.000671387, 0.000640869, 0.000610352, 0.000610352,
   0.000640869, 0.000671387, 0.000732422, 0.000762939, 0.000732422,
   0.000671387, 0.000640869, 0.000579834, 0.000518799, 0.000488281,
   0.000457764, 0.000457764, 0.000427246, 0.000427246, 0.000396729,
   0.000366211, 0.000366211, 0.000396729, 0.000488281, 0.000549316,
   0.000518799, 0.000488281, 0.000518799, 0.000488281, 0.000457764,
  0.000488281, 0.000427246, 0.000366211, 0.000274658, 0.000244141,
  0.000244141, 0.000244141, 0.000244141, 0.000213623, 0.000274658,
  0.000274658, 0.000305176, 0.000305176, 0.000213623, 0.000183105,
  0.000152588, 0.000183105, 0.000152588, 0.000152588, 0.00012207,
  0.00012207, 0.000152588, 0.00012207, 0.00012207,
  0.000015546914727030923, 0.000015546914727030923,
  0.000015546914727030923, 0.000152588, 0.000183105, 0.000183105,
  0.000213623, 0.000213623, 0.000152588, 0.000183105, 0.000335693,
  0.000518799, 0.000610352, 0.000671387, 0.000732422, 0.00088501,
  0.000976563, 0.00106812, 0.00106812, 0.000946045, 0.000640869,
  0.000015546914727030923, -0.000518799, -0.00109863, -0.00183105,
-0.00262451, -0.00201416, 0.000427246, 0.00134277,
  -0.000579834, 0.0017395, 0.00830078, 0.00881958,
  0.00228882, -0.00448608, -0.00704956, -0.00479126, -0.000610352,
  0.00183105, 0.0017395, 0.000854492, 0.000701904, 0.00106812,
  0.00088501, 0.000549316, 0.00119019, 0.00228882, 0.00265503,
  0.00128174, -0.00222778, -0.00524902, -0.00500488, -0.00238037,
  0.000015546914727030923, 0.00125122, 0.00183105, 0.00210571,
  0.00167847, 0.00012207, -0.00140381, -0.00170898, -0.000457764,
  0.00137329, 0.00137329, -0.000274658, -0.00100708, -0.000427246,
  0.00011805873894861419, -0.000015546914727030923, -0.000732422,
-0.00112915, -0.000640869, 0.000244141, 0.000488281,
  0.000152588, -0.000305176, -0.000305176, 0.00011805873894861419,
  0.000427246, 0.000701904, 0.000671387,
  0.000335693, -0.003777879646355654, -0.000396729, -0.000366211,
-0.003777879646355654, 0.000366211, 0.000579834, 0.000457764,
  0.000183105, -0.00012207, -0.000274658, -0.000244141, -0.000183105,
-0.000305176, -0.000518799, -0.000518799, -0.000427246, -0.000427246,
-0.000305176, 0.00011805873894861419, 0.000366211, 0.000549316,
  0.000549316, 0.000244141, -0.00012207, -0.000274658, -0.000152588,
  0.003777879646355654, 0.000183105, 0.000335693,
  0.000305176, -0.00011805873894861419, -0.000701904, -0.0010376,
-0.000793457, -0.000305176, -0.00012207, -0.000274658, -0.000610352,
-0.000793457, -0.000854492, -0.00088501, -0.0010376}
There are a 193 data points, and I took the DFT of them
a = Fourier[{v}, FourierParameters -> {1, 1}]

Then I ploted the real and imaginary parts
ListLinePlot[Re /@ a[[1]], PlotRange -> All]
ListLinePlot[Im /@ a[[1]], PlotRange -> All]

How can I write an if statement in Mathmatica to only plot points that are less than .03 for data points between 1 to 96, and less than .25 for all data points between 97 to 193?

Thank you in adavance.
POSTED BY: sean roubion
3 Replies
Posted 10 years ago
If you want to drop points from the plot which exceed some threshold, but you want to keep th rest of the points in their original position so that you do not shift the spectra, or possibly shift the spectra differently for the real and imaginary components then you might want to use Transpose[{Range[Length],a}] to add an index to each point. Then when you drop points the index would remain and you could use ListPlot with Joined->True and perhaps even split the points into separate lists where you have eliminated points so that you do not display lines where they do not exist.

How much work you need to put into this depends on how precise you want the resulting plot to be. You could even use something like Min or Max to replace elements that are greater than a bound with the value of the bound if that display is acceptable.
POSTED BY: Bill Simpson
(fyi, it looks like http://community.wolfram.com/groups/-/m/t/248351 for a reason.)
POSTED BY: Bruce Miller
Perhaps something like (for the real case):
a = Fourier[{v}, FourierParameters -> {1, 1}];

a1 = Select[Take[Re /@ a[[1]], {1, 96}], # < .03 &] ;

a2 = Select[Take[Re /@ a[[1]], {97, 193}], # < .25 &] ;

realPoints = Flatten[{a1, a2}];
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract