Home | Develop | Download | Contact
testprog9.c

Test del Filtro Iir pasa alto, para dos señales sinusoidales en pi/32, 3*pi/4.

Autor
Fernando Pujaico Rivera
Fecha
10-02-2012
Ademas la señal de entrada tiene una constante igual 1. La frecuencia de muestro es 2*pi.
Test de un filtro IIR pasa alto de primer orden con polo en a=0.95.

\[x[n]=1+sin(\frac{\pi}{32}n)+sin(\frac{3\pi}{4}n+\frac{\pi}{16})\]

\[H(z)=\frac{1}{20}\frac{(1+z^{-1})}{(1-0.9z^{-1})} \]


test1grafico1.png
Señal de entrada x[n].
test9grafico2.png
Señal de salida y[n].
/*
* testprog9.c
*
* Copyright 2011 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#include <config.h>
#include <stdlib.h>
#include <pds/pdsdf.h>
#include <pds/pdsvector.h>
#include "extras.h"
#include <math.h>
int main(int argc, char** argv)
{
PdsIir1HP *IIR1HP=NULL;
PdsDfReal x,y;
PdsDfReal a=0.95;
FILE *fd=NULL;
char DATAFILE[]="datos.txt";
char OCTAVEFILE[]="plotinoctave.m";
PdsVector *X=NULL;
PdsVector *Y1=NULL;
PdsVector *Y2=NULL;
N=128;
X=pds_vector_new(N);
Y1=pds_vector_new(N);
Y2=pds_vector_new(N);
IIR1HP=pds_iir1hp_new(a);
for(n=0;n<N;n++)
{
x=1.0+sin(M_PI*n/32.0)+sin(3.0*M_PI*n/4.0+M_PI/16.0);
X->V[n]=x;
Y1->V[n]=y;
}
pds_iir1hp_free(IIR1HP);
IIR1HP=pds_iir1hp_new(a);
pds_iir1hp_free(IIR1HP);
fd=fopen(DATAFILE,"w");
if(fd==NULL) return EXIT_FAILURE;
pds_vector_fprintf(X,fd);
pds_vector_fprintf(Y1,fd);
pds_vector_fprintf(Y2,fd);
fclose(fd);
pds_octave_plot_lin(OCTAVEFILE,DATAFILE);
return EXIT_SUCCESS;
}

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed