Home | Develop | Download | Contact
testprog9.c
1 /*
2  * testprog9.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  PdsIir1HP *IIR1HP=NULL;
52  PdsDfReal x,y;
53  PdsDfReal a=0.95;
54  PdsDfNatural n,N;
55  FILE *fd=NULL;
56  char DATAFILE[]="datos.txt";
57  char OCTAVEFILE[]="plotinoctave.m";
58  PdsVector *X=NULL;
59  PdsVector *Y1=NULL;
60  PdsVector *Y2=NULL;
61 
62  N=128;
63  X=pds_vector_new(N);
64  Y1=pds_vector_new(N);
65  Y2=pds_vector_new(N);
66 
67  IIR1HP=pds_iir1hp_new(a);
68  for(n=0;n<N;n++)
69  {
70  x=1.0+sin(M_PI*n/32.0)+sin(3.0*M_PI*n/4.0+M_PI/16.0);
71  pds_iir1hp_evaluate_value(IIR1HP,x,&y);
72 
73  X->V[n]=x;
74  Y1->V[n]=y;
75  }
76  pds_iir1hp_free(IIR1HP);
78 
80  IIR1HP=pds_iir1hp_new(a);
81  pds_iir1hp_evaluate_vector(IIR1HP,X,Y2);
82  pds_iir1hp_free(IIR1HP);
84 
85  fd=fopen(DATAFILE,"w");
86  if(fd==NULL) return EXIT_FAILURE;
87  pds_vector_fprintf(X,fd);
88  pds_vector_fprintf(Y1,fd);
89  pds_vector_fprintf(Y2,fd);
90  fclose(fd);
91 
92  pds_octave_plot_lin(OCTAVEFILE,DATAFILE);
93 
94  return EXIT_SUCCESS;
95 }
PdsIir1HP * pds_iir1hp_new(PdsDfReal a)
Crea un filtro IIR pasa alto de primer orden.
Una estructura tipo PdsIir1HP .
Definition: pdsiir1hp.h:80
void pds_iir1hp_free(PdsIir1HP *IIR1HP)
Libera el filtro pasa alto de tipo PdsIir1HP.
int pds_iir1hp_evaluate_value(PdsIir1HP *IIR1HP, PdsDfReal x, PdsDfReal *y)
Evalúa el filtro IIR pasa alto con el valor de entrada x, el resultado es cargado en y...
unsigned int PdsDfNatural
Definition: pdsdfglobal.h:47
float PdsDfReal
Definition: pdsdfglobal.h:42
int pds_iir1hp_evaluate_vector(PdsIir1HP *IIR1HP, const PdsVector *x, PdsVector *y)
Evalua el filtro IIR pasa alto con el vector de entrada x, el resultado es cargado en el vector y...

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed