Home | Develop | Download | Contact
 Todo Estructuras de Datos Funciones Variables 'typedefs' Grupos Páginas
testprograma2.c
1 /*
2  * testprograma2.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 
30 #include <config.h>
31 #include <stdlib.h>
32 #include <pds/pdsft.h>
33 #include <pds/pdsvector.h>
34 #include <pds/pdscvector.h>
35 #include <math.h>
36 
37 #include "extras.h"
38 
39 
40 int main(int argc, char** argv)
41 {
42 
43  PdsStft *STFT=NULL;
44 
45  PdsVector *Vin=NULL;
46  PdsCVector *Vout=NULL;
47  PdsVector *V=NULL;
48  PdsRaReal max;
49 
50  PdsFtNatural i,j,L=42,N=64,T=32;
51 
52  FILE *fd=NULL;
53 
54  PdsMatrix * M=NULL;
55 
57 
58  M=pds_matrix_new (N/2,T);
59 
60  STFT=pds_stft_new(L,&N);
61  pds_stft_set_window_gauss(STFT,0.5);
62 
63  Vin=pds_vector_new(L);
64  Vout=pds_cvector_new(N);
65  V=pds_vector_new(N);
66 
67  for(i=0;i<T;i++)
68  {
69  for(j=0;j<L;j++) Vin->V[j]=sin(2.0*M_PI*(2.0 + (L*i*1.0+j)/(2.0*L))*j*1.0/L);
70 
71  pds_stft_evaluate_real(STFT,Vout,Vin);
72 
73  pds_cvector_modulus2(Vout,V);
74  //pds_vector_get_max_value(V,&max);
75  //pds_vector_mul_value (V, 1.0/max);
76 
77  pds_matrix_copy_vector_col(M,V,i);
78  }
79 
80 
81  pds_octplot_surf_matrix_in_png(M,"Tiempo ID","Frecuencia ID","|STFT|","graficaVout.m","graficaVout.png");
82 
83  pds_cvector_free(Vout);
84  pds_vector_free(Vin);
85  pds_vector_free(V);
86  pds_matrix_free(M);
87  pds_stft_free(STFT);
88 
89  return EXIT_SUCCESS;
90 }
91 
92 
93 
unsigned int PdsFtNatural
Definition: pdsftglobal.h:50
void pds_stft_free(PdsStft *STFT)
Libera una estructura de tipo puntero PdsStft.
int pds_stft_set_window_gauss(PdsStft *STFT, PdsFtReal Sigma)
Copia una ventana de Gauss a W de la STFT.
PdsStft * pds_stft_new(PdsFtNatural L, PdsFtNatural *N)
Crea una estructura de tipo PdsStft, para generar una STFT de L puntos de entrada y N puntos de salid...
int pds_stft_evaluate_real(PdsStft *STFT, PdsCVector *Out, const PdsVector *In)
Evalua la STFT de un vetor real. El tamanho del vector Out debe ser igual al número de puntos de sali...
Estructura tipo PdsStft. Esta estructura genera una Transformada de Fourier de Tiempo Reducido de N p...
Definition: pdsstft.h:79

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed