libdspl-2.0/examples/src/sinc_test.c

44 wiersze
1.2 KiB
C

2018-09-20 20:22:29 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dspl.h"
#define N 1000
2019-11-04 14:05:33 +00:00
int main(int argc, char* argv[])
2018-09-20 20:22:29 +00:00
{
Examples style changed Changes to be committed: modified: examples/src/array_test.c modified: examples/src/bessel_i0.c modified: examples/src/bilinear_test.c modified: examples/src/butter_ap_test.c modified: examples/src/butter_ap_zp_test.c modified: examples/src/cheby1_ap_test.c modified: examples/src/cheby1_ap_zp_test.c modified: examples/src/cheby2_ap_test.c modified: examples/src/cheby2_ap_zp_test.c modified: examples/src/cheby_poly1_test.c modified: examples/src/cheby_poly2_test.c modified: examples/src/complex_test.c modified: examples/src/conv_fft_cmplx_test.c modified: examples/src/conv_fft_test.c modified: examples/src/conv_test.c modified: examples/src/dft_cmplx_test.c modified: examples/src/dft_test.c modified: examples/src/dspl_info_test.c modified: examples/src/ellip_ap_test.c modified: examples/src/ellip_ap_zp_test.c modified: examples/src/ellip_landen_test.c modified: examples/src/fft_cmplx_test.c modified: examples/src/fft_test.c modified: examples/src/filter_iir_test.c modified: examples/src/fir_linphase_test.c modified: examples/src/gnuplot_script_test.c modified: examples/src/idft_cmplx_test.c modified: examples/src/ifft_cmplx_test.c modified: examples/src/iir_bstop.c modified: examples/src/iir_lpf.c modified: examples/src/iir_test.c modified: examples/src/matrix_eig.c modified: examples/src/matrix_mul.c modified: examples/src/matrix_print.c modified: examples/src/matrix_transpose.c modified: examples/src/polyroots_test.c modified: examples/src/randb_test.c modified: examples/src/randi_test.c modified: examples/src/randn_test.c modified: examples/src/randu_accuracy_test.c modified: examples/src/randu_test.c modified: examples/src/sinc_test.c modified: examples/src/sine_int_test.c modified: examples/src/writetxt_3d_test.c
2020-07-18 06:34:52 +00:00
void* hdspl; /* DSPL handle */
void* hplot; /* GNUPLOT handle */
hdspl = dspl_load(); /* Load DSPL function */
double x[N], y[N];
linspace(-10.0, 10.0, N , DSPL_SYMMETRIC, x);
sinc(x, N, 1.0, y);
writetxt(x, y, N, "dat/sinc_test_1.0.txt");
sinc(x, N, M_PI, y);
writetxt(x, y, N, "dat/sinc_test_pi.txt");
sinc(x, N, 2.0*M_PI, y);
writetxt(x, y, N, "dat/sinc_test_2pi.txt");
/* plotting by GNUPLOT */
gnuplot_create(argc, argv, 560, 280, "img/sinc_test.png", &hplot);
gnuplot_cmd(hplot, "set grid");
gnuplot_cmd(hplot, "set xlabel 'x'");
gnuplot_cmd(hplot, "set ylabel 'sinc(x,a)'");
gnuplot_cmd(hplot, "set yrange [-0.25:1.1]");
gnuplot_cmd(hplot, "plot 'dat/sinc_test_1.0.txt' with lines title 'a = 1.0'");
gnuplot_cmd(hplot, "replot 'dat/sinc_test_pi.txt' with lines title 'a = pi'");
gnuplot_cmd(hplot, "replot 'dat/sinc_test_2pi.txt' with lines title 'a = 2pi'");
gnuplot_close(hplot);
dspl_free(hdspl); // free dspl handle
return 0;
2018-09-20 20:22:29 +00:00
}