home *** CD-ROM | disk | FTP | other *** search
- # include <math.h>
- # include <graph.h>
- # include "stdlib.h"
- # include "stdio.h"
- # include "miscio.h"
- # include "fft.h"
- # include "worlddr.h"
- # include "segraph.h"
-
-
-
- float xdata[512], ydata[512], tdata[512];
- int lower,upper,n,i,j,k;
- char c;
-
-
-
- void main() /* main program fft */
- {
- n = 128;
- for ( i= 0; i <= n-1; i++ )
- {
- xdata[i] = 6.0 * cos(M_PI*i/(19.0 + frandom())) + 3.5 *cos(M_PI*i/32.0 ) + 3.0 * sin(M_PI*i/4.0) ;
- ydata[i] = 0.0;
-
- tdata[i] = i;
- }
- /****************************************************
- - IF YOU WANT TO CONFIGURE FOR CGA 4 COLORS
- CHOOSE InitSEGraphics(1);
- - HERCULES SUPPORT IS NOW INCLUDED IN MICROSOFT
- C VERSION 5.1. IF YOU WANT TO USE THE
- HERCULES DRIVER YOU MUST FIRST INSTALL
- MSHERC.COM FROM DOS BY TYPING
- msherc<enter>
- THEN IN YOUR MAIN PROGRAM CALL
- InitSEGraphics(12);
- - REFER TO THE README.DOC FILE - PART 3
- INCLUDED IN YOUR MICROSOFT C 5.1 COMPILER
- FOR DETAILS ON ADDED HERCULES SUPPORT.
- **************************************************/
- InitSEGraphics(6);
-
- SetCurrentWindow(3);
- ClearWindow();
- SetAxesType(0,0);
- BorderCurrentWindow(15);
- SelectColor(1);
- AutoAxes(tdata,xdata,n,0);
- LinePlotData(tdata, xdata, n,2, 1);
- SelectColor(1);
- TitleWindow("Original data");
-
-
-
- PowerSpectrumCalc(xdata,ydata,n,0.01);
- SetCurrentWindow(4);
- ClearWindow();
- BorderCurrentWindow(15);
- SelectColor(1);
- SetAxesType(0,0);
- AutoAxes(ydata,xdata,n / 2,0);
- LinePlotData(ydata, xdata, n / 2,4, 1);
-
-
- TitleWindow("Power Spectrum");
- TitleXAxis("Frequency");
- TitleYAxis("Power Density");
-
- scanf( "%c",&c );
-
- CloseSEGraphics();
-
- }
-
-
-