Home | Develop | Download | Contact
example1a.c
1 /*
2  * example1a.c
3  *
4  * Copyright 2011 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  *
21  */
22 
23 
41 #include <config.h>
42 #include <stdlib.h>
43 #include <pds/pdsdf.h>
44 #include <pds/pdsvector.h>
45 #include "extras.h"
46 #include <math.h>
47 
48 int main(int argc, char** argv)
49 {
51  PdsIir *IIR1=NULL;
52  PdsVector *hden=NULL;
53  PdsVector *hnum=NULL;
54 
55  PdsDfReal x,y;
56  PdsDfNatural n,N;
57 
58  PdsVector *X=NULL;
59  PdsVector *Y=NULL;
60 
61  //-------------------------- Creando filtro IIR --------------------------//
62 
63  // hnum=[ 1/20 1/20]
64  hnum=pds_vector_new_args(2, 1/20.0,1/20.0);
65  // hden=[1.0 -0.9]
66  hden=pds_vector_new_args(2, 1.0, -0.9);
67 
68  IIR1=pds_iir_new(hnum,hden);
69 
70  //------------------------------- Filtrando ------------------------------//
71 
72  N=128;
73  X=pds_vector_new(N);
74  Y=pds_vector_new(N);
75 
76  for(n=0;n<N;n++)
77  {
78  x=1.0+sin(M_PI*n/32.0)+sin(3.0*M_PI*n/4.0+M_PI/16.0);
79  pds_iir_evaluate_value(IIR1,x,&y);
80 
81  X->V[n]=x;
82  Y->V[n]=y;
83  }
84 
85 
86  //-------------------------- Plotando resultados -------------------------//
87 
88  pds_vector_octave_png_plot(NULL,X,"n","X",NULL,"example1ax.png");
89  pds_vector_octave_png_plot(NULL,Y,"n","Y",NULL,"example1ay.png");
90 
91  //---------------------------- Limpiando todo ----------------------------//
92 
93  pds_vector_free(hnum);
94  pds_vector_free(hden);
95  pds_iir_free(IIR1);
96 
97  return EXIT_SUCCESS;
98 }
int pds_iir_evaluate_value(PdsIir *IIR, PdsDfReal x, PdsDfReal *y)
Evalua el filtro IIR con el valor de entrada x, el resultado es cargado en y.
void pds_iir_free(PdsIir *IIR)
Libera el filtro de tipo PdsIir.
unsigned int PdsDfNatural
Definition: pdsdfglobal.h:47
Una estructura tipo PdsIir .
Definition: pdsiir.h:86
float PdsDfReal
Definition: pdsdfglobal.h:42
PdsIir * pds_iir_new(const PdsVector *hnum, const PdsVector *hden)
Crea un filtro IIR con parametros hnum y hden.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed