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


Groups > comp.graphics.apps.gnuplot > #3136 > unrolled thread

Need some help -- plot fast fourier transform

Started bydakupoto@gmail.com
First post2015-11-20 20:56 -0800
Last post2017-01-28 17:08 -0800
Articles 10 — 7 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  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

#3136 — Need some help -- plot fast fourier transform

Fromdakupoto@gmail.com
Date2015-11-20 20:56 -0800
SubjectNeed some help -- plot fast fourier transform
Message-ID<ea07f149-8203-4653-a767-3313ddbbc8af@googlegroups.com>
Could some Gnuplot guru please provide any simple 
example script for plotting FFT(fast fourier 
transform). Currently I am just able to create 
scatter plots of FFT output, but I would much
rather have the simple line graphs. All hints/
suggestions would be greatly appreciated - thans 
in advance for your help.

[toc] | [next] | [standalone]


#3137

FromKarl-Friedrich Ratzsch <mail.kfr@gmx.net>
Date2015-11-21 11:43 +0100
Message-ID<n2phrs$je3$1@solani.org>
In reply to#3136
Am 21.11.2015 um 05:56 schrieb dakupoto@gmail.com:
> Could some Gnuplot guru please provide any simple 
> example script for plotting FFT(fast fourier 
> transform). Currently I am just able to create 
> scatter plots of FFT output, but I would much
> rather have the simple line graphs. All hints/
> suggestions would be greatly appreciated - thans 
> in advance for your help.

This doesn't explain your problem, just the direction from where it
landed on your feet.

I'd say you don't want a guru, you want a nanny. Sorry.

[toc] | [prev] | [next] | [standalone]


#3139

Fromdakupoto@gmail.com
Date2015-11-21 19:13 -0800
Message-ID<82271787-2bb8-4291-8705-e6eb4656b610@googlegroups.com>
In reply to#3137
On Saturday, November 21, 2015 at 5:43:09 AM UTC-5, Karl-Friedrich Ratzsch wrote:
> Am 21.11.2015 um 05:56 schrieb dakupoto@gmail.com:
> > Could some Gnuplot guru please provide any simple 
> > example script for plotting FFT(fast fourier 
> > transform). Currently I am just able to create 
> > scatter plots of FFT output, but I would much
> > rather have the simple line graphs. All hints/
> > suggestions would be greatly appreciated - thans 
> > in advance for your help.
> 
> This doesn't explain your problem, just the direction from where it
> landed on your feet.
> 
> I'd say you don't want a guru, you want a nanny. Sorry.

The problem is self-explanatory. 
I have generated a set of Fast 
Fourier Transform values(amplitude,
phase) using a simple C language 
program, and the implementation is 
based on the steps described in 
Numerical Recipes in C. The C 
language program is compiled with 
GCC, running on a Fedora 18 machine. 
If I start gnuplot, and use use 
the command line 
plot 'testout' using 1:2 with lines; 
I get a beautiful symmetrical flower 
like pattern in the plot window NOT 
the set of symmetrical spikes 
associated with a spectrum.
I have used Gnuplot for years, with 
no complaints. I tried other commamds
as:
plot 'testout' using 1:2 pt 5 ps 7
and now I get a set of symmetrical 
little squares in the plot window,
where each square represents the 
peak of each spike, but I DO NOT 
see the spikes. So, obviously 
there must be some other commands
that I need to use, which I do not
know. May I know what these other
commands are ?
I am sure I have explained the problem
clearly. I expect  meaningful response.
   

[toc] | [prev] | [next] | [standalone]


#3140

FromRichard Owlett <rowlett@cloud85.net>
Date2015-11-22 04:58 -0600
Message-ID<mKmdnfLtOfQiAszLnZ2dnUU7-f2dnZ2d@supernews.com>
In reply to#3139
On 11/21/2015 9:13 PM, dakupoto@gmail.com wrote:
> On Saturday, November 21, 2015 at 5:43:09 AM UTC-5, Karl-Friedrich Ratzsch wrote:
>> Am 21.11.2015 um 05:56 schrieb dakupoto@gmail.com:
>>> Could some Gnuplot guru please provide any simple
>>> example script for plotting FFT(fast fourier
>>> transform). Currently I am just able to create
>>> scatter plots of FFT output, but I would much
>>> rather have the simple line graphs. All hints/
>>> suggestions would be greatly appreciated - thans
>>> in advance for your help.
>>
>> This doesn't explain your problem, just the direction from where it
>> landed on your feet.
>>
>> I'd say you don't want a guru, you want a nanny. Sorry.
>
> The problem is self-explanatory.
> I have generated a set of Fast
> Fourier Transform values(amplitude,
> phase) [SNIP;]
> I get a beautiful symmetrical flower
> like pattern in the plot window [snip]
> I am sure I have explained the problem
> clearly. I expect  meaningful response.

Gnuplot worked.
Ask yourself:
   1. What is an independent variable?
   2. What is a dependent variable?

[toc] | [prev] | [next] | [standalone]


#3141

FromThomas Wagner <thomas.wagner.marl@freenet.de>
Date2015-11-25 00:51 +0100
Message-ID<n32t5a$h7u$1@news.albasani.net>
In reply to#3139
Am 22.11.2015 um 04:13 schrieb dakupoto@gmail.com:
> On Saturday, November 21, 2015 at 5:43:09 AM UTC-5, Karl-Friedrich Ratzsch wrote:
>> Am 21.11.2015 um 05:56 schrieb dakupoto@gmail.com:
>>> Could some Gnuplot guru please provide any simple
>>> example script for plotting FFT(fast fourier
>>> transform). Currently I am just able to create
>>> scatter plots of FFT output, but I would much
>>> rather have the simple line graphs. All hints/
>>> suggestions would be greatly appreciated - thans
>>> in advance for your help.
>>
>> This doesn't explain your problem, just the direction from where it
>> landed on your feet.
>>
>> I'd say you don't want a guru, you want a nanny. Sorry.
>
> The problem is self-explanatory.
> I have generated a set of Fast
> Fourier Transform values(amplitude,
> phase) using a simple C language
> program, and the implementation is
> based on the steps described in
> Numerical Recipes in C. The C
> language program is compiled with
> GCC, running on a Fedora 18 machine.
> If I start gnuplot, and use use
> the command line
> plot 'testout' using 1:2 with lines;
> I get a beautiful symmetrical flower
> like pattern in the plot window NOT
> the set of symmetrical spikes
> associated with a spectrum.
> I have used Gnuplot for years, with
> no complaints. I tried other commamds
> as:
> plot 'testout' using 1:2 pt 5 ps 7
> and now I get a set of symmetrical
> little squares in the plot window,
> where each square represents the
> peak of each spike, but I DO NOT
> see the spikes. So, obviously
> there must be some other commands
> that I need to use, which I do not
> know. May I know what these other
> commands are ?
> I am sure I have explained the problem
> clearly. I expect  meaningful response.
>
>

When reading about the flower like plot my first suspicion was that your 
data file may probably not contain sorted data. A line plot will then 
show such funny figures, a point plot of the same data set would not 
reveal unsorted data. I have used NRC's FFT algorithms myself many years 
ago and I vaguely remember that the data returned by the functions had 
to be sorted manually.

Gnuplot plots data as presented in the data files unchanged unless you 
tell gnuplot to do so. That is why I would check the contents of the 
data file first.

Hope this helps,
Thomas

[toc] | [prev] | [next] | [standalone]


#3142

FromHans-Bernhard Bröker <HBBroeker@t-online.de>
Date2015-11-25 01:25 +0100
Message-ID<dbkdgcF4ls1U1@mid.dfncis.de>
In reply to#3139
Am 22.11.2015 um 04:13 schrieb dakupoto@gmail.com:

> The problem is self-explanatory.

No, it really is not.

How is anybody not sitting in front of your machine supposed to know 
what the output of that entirely unknown FFT program of yours looks 
like, without being shown as much as a small sample of it?

> I am sure I have explained the problem clearly.

Not really.

 > I expect meaningful response.

And that's exactly the kind of attitude that makes me _not_ want to help 
you.  If you want to use that kind of language, you'll have to pay 
someone to put up with it.

[toc] | [prev] | [next] | [standalone]


#3550

Fromdrmcnelson@gmail.com
Date2017-01-28 17:47 -0800
Message-ID<23acc91e-8c60-44e4-a31d-fea3ce2a9c87@googlegroups.com>
In reply to#3139
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.

[toc] | [prev] | [next] | [standalone]


#3552

FromJohn Edwards <johned0@gmail.com>
Date2017-01-31 04:18 -0800
Message-ID<0391b062-6b95-402e-a4d3-4ffb6606c4f7@googlegroups.com>
In reply to#3550
An old thread come back to life, that I didn't see the first time around.
I regularly plot FFT (and other DSP) results from C/C++. I used to hack new functions every time I wanted to plot a new dataset. In the end I realized that it would save me a lot of time to put these into a library. It is available here : https://sourceforge.net/projects/gnuplotc/.
Enjoy
John

[toc] | [prev] | [next] | [standalone]


#3138

FromRichard Owlett <rowlett@cloud85.net>
Date2015-11-21 10:07 -0600
Message-ID<EYmdnX3GPaYwC83LnZ2dnUU7-aWdnZ2d@supernews.com>
In reply to#3136
On 11/20/2015 10:56 PM, dakupoto@gmail.com wrote:
> Could some Gnuplot guru please provide any simple
> example script for plotting FFT(fast fourier
> transform). Currently I am just able to create
> scatter plots of FFT output, but I would much
> rather have the simple line graphs. All hints/
> suggestions would be greatly appreciated - thans
> in advance for your help.
>

Browse https://www.google.com/search?q=how+to+ask+questions
[Hint] You didn't tell us what you used or did ;/

P.S. You're not first [not last] to poorly frame a question.

[toc] | [prev] | [next] | [standalone]


#3549

Fromdrmcnelson@gmail.com
Date2017-01-28 17:08 -0800
Message-ID<6e050bc2-763f-4694-9ca0-8781f221566b@googlegroups.com>
In reply to#3136
On Friday, November 20, 2015 at 11:56:31 PM UTC-5, daku...@gmail.com wrote:
> Could some Gnuplot guru please provide any simple 
> example script for plotting FFT(fast fourier 
> transform). Currently I am just able to create 
> scatter plots of FFT output, but I would much
> rather have the simple line graphs. All hints/
> suggestions would be greatly appreciated - thans 
> in advance for your help.

Assuming you have two columns, real and complex, you might looking for something like

plot 'myfftfile' using 0:($1**2+$2**2)

That will plot the amplitude versus bin number

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web