SigPack - the C++ signal processing library
 
Loading...
Searching...
No Matches
filter_plot.cpp
Go to the documentation of this file.
1
8#include "sigpack.h"
9
10using namespace arma;
11using namespace sp;
12
13int main()
14{
15 gplot gp;
16 gp.window( "Filter plots", 10, 10, 700, 700 );
17
18 vec Mg( 1024 );
19 vec Ph( 1024 );
20 vec a, b;
21 a = { 1 };
22 b = fir1( 44, 0.25 );
23 Mg = 20 * log10( freqz( b, a, 1024 ) );
24 Ph = phasez( b, a, 1024 );
25
26 // Plot
27 gp.set_term( "qt" );
28 gp.grid_on();
29 gp.send2gp( "set multiplot layout 2, 1" );
30 gp.send2gp( "set xtics (\"0\" 1,\"0.5\" 512,\"1\" 1024)" ); // Direct call to
31 // gnuplot pipe
32 gp.ylabel( "Magnitude [dB]" );
33 gp.xlabel( "Frequency [f/Fs]" );
34 gp.plot_add( Mg, "Filter" );
35 gp.plot_show();
36 gp.send2gp( "set xtics (\"0\" 1,\"0.5\" 512,\"1\" 1024)" ); // Direct call to
37 // gnuplot pipe
38 gp.ylabel( "Phase [rad]" );
39 gp.xlabel( "Frequency [f/Fs]" );
40 gp.plot_add( Ph, "Filter" );
41 gp.plot_show();
42 gp.send2gp( "unset multiplot" );
43
44 return 0;
45}
Gnuplot class.
Definition gplot.h:27
void plot_show(void)
Show plots.
Definition gplot.h:401
void grid_on(void)
Set grid.
Definition gplot.h:229
void xlabel(const char *label)
Set label for X-axis.
Definition gplot.h:246
void ylabel(const char *label)
Set label for X-axis.
Definition gplot.h:258
void send2gp(const char *cmdstr)
Send command to Gnuplot pipe.
Definition gplot.h:143
void set_term(const char *ttype)
Set output terminal.
Definition gplot.h:757
void plot_add(const T1 &x, const T2 &y, const std::string lb, const std::string ls="lines")
Push plot y vs. x with label and linespec.
Definition gplot.h:325
void window(const int fig, const char *name, const int x, const int y, const int width, const int height)
Configure the figure used Windows environment.
Definition gplot.h:190
int main()
arma_inline arma::vec phasez(const arma::vec b, const arma::vec a, const arma::uword K=512)
Frequency phase response function. Calculates the frequency phase response.
Definition filter.h:803
arma_inline arma::vec fir1(const arma::uword M, const double f0)
FIR lowpass design function. FIR lowpassdesign using windows method (hamming window)....
Definition filter.h:637
arma_inline arma::vec freqz(const arma::vec b, const arma::vec a, const arma::uword K=512)
Frequency magnitude response function. Calculates the frequency magnitude response.
Definition filter.h:790
Definition base.h:8