Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #3550

Re: Need some help -- plot fast fourier transform

X-Received by 10.107.138.233 with SMTP id c102mr4409998ioj.18.1485654475407; Sat, 28 Jan 2017 17:47:55 -0800 (PST)
X-Received by 10.157.43.215 with SMTP id u81mr1242780ota.15.1485654475380; Sat, 28 Jan 2017 17:47:55 -0800 (PST)
Path csiph.com!weretis.net!feeder6.news.weretis.net!news.glorb.com!r185no1005441ita.0!news-out.google.com!78ni21824itm.0!nntp.google.com!r185no1005440ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.graphics.apps.gnuplot
Date Sat, 28 Jan 2017 17:47:54 -0800 (PST)
In-Reply-To <82271787-2bb8-4291-8705-e6eb4656b610@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=24.45.13.150; posting-account=i227SwoAAAD1oAKm4JdAo91Sg8cLhPKa
NNTP-Posting-Host 24.45.13.150
References <ea07f149-8203-4653-a767-3313ddbbc8af@googlegroups.com> <n2phrs$je3$1@solani.org> <82271787-2bb8-4291-8705-e6eb4656b610@googlegroups.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <23acc91e-8c60-44e4-a31d-fea3ce2a9c87@googlegroups.com> (permalink)
Subject Re: Need some help -- plot fast fourier transform
From drmcnelson@gmail.com
Injection-Date Sun, 29 Jan 2017 01:47:55 +0000
Content-Type text/plain; charset=UTF-8
Xref csiph.com comp.graphics.apps.gnuplot:3550

Show key headers only | View raw


Here is a more complete answer:

The output of an FFT is a list of complex values.  If you use the realft algorothm from Numrec or something similar,  for N discrete sampled real values, you get N/2 complex values, or N/2 pairs of real and imaginary values.  

As I recall, NumRec packs them into doubles. The array elements at even indices are the real part and the array elements at odd indices are the imaginary part.

You need to output them from your c program as two columns, d[2*i], d[2*i+1], or output the square magnitude of each pair (d[2*i]*d[2*i]+d[2*i+1]*d[2*i+1])

If you output them as two columns, you plot them as

   sqrmag(a,b) = a**2 +b**2

   plot 'myfile' using 0:(sqrmag($1,$2))

or if you output them as the square magnitude, you plot them as

   plot 'myfile' using 0:1

Note that these command graph the spectrum versus bin number.

If you want to plot them versus frequency,  replace the "0" by 

(($0/Ndata)*samplingrate)

where the number of frequency bins Nbins = Ndata/2,  or you can do that in your program and output an extra column for the frequency and adjust the plot commands accordingly.

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Need some help -- plot fast fourier transform dakupoto@gmail.com - 2015-11-20 20:56 -0800
  Re: Need some help -- plot fast fourier transform Karl-Friedrich Ratzsch <mail.kfr@gmx.net> - 2015-11-21 11:43 +0100
    Re: Need some help -- plot fast fourier transform dakupoto@gmail.com - 2015-11-21 19:13 -0800
      Re: Need some help -- plot fast fourier transform Richard Owlett <rowlett@cloud85.net> - 2015-11-22 04:58 -0600
      Re: Need some help -- plot fast fourier transform Thomas Wagner <thomas.wagner.marl@freenet.de> - 2015-11-25 00:51 +0100
      Re: Need some help -- plot fast fourier transform Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-11-25 01:25 +0100
      Re: Need some help -- plot fast fourier transform drmcnelson@gmail.com - 2017-01-28 17:47 -0800
        Re: Need some help -- plot fast fourier transform John Edwards <johned0@gmail.com> - 2017-01-31 04:18 -0800
  Re: Need some help -- plot fast fourier transform Richard Owlett <rowlett@cloud85.net> - 2015-11-21 10:07 -0600
  Re: Need some help -- plot fast fourier transform drmcnelson@gmail.com - 2017-01-28 17:08 -0800

csiph-web