Tu as quoi comme erreurs ... ?
Qu'est-ce qui ne marche pas à partir de 4 ... ? Ton programme plante ? Il ne fait pas ce que tu veux ? ...
Un peu de précision aide grandement à la compréhension du problème ...
Version imprimable
Tu as quoi comme erreurs ... ?
Qu'est-ce qui ne marche pas à partir de 4 ... ? Ton programme plante ? Il ne fait pas ce que tu veux ? ...
Un peu de précision aide grandement à la compréhension du problème ...
En fait, je ne récupère pas les mêmes valeurs que dans le tableau de départ. DAns la version que je t'ai donné sa fonctionne. Mais maintenant je l'ai intégré dans un autre programme.
J'ai ceci:
Code:
1
2
3
4
5
6 avant interpolation : 0.020011 0.005800 -0.013472 -0.034863 -0.074317 -0.072955 -0.055436 -0.021135 0.007778 0.080625 0.161111 0.237868 0.318392 0.336664 0.312715 0.244677 0.117179 -0.004656 -0.134167 -0.255710 -0.334736 -0.414295 -0.459121 -0.466115 -0.416831 -0.371199 -0.308749 -0.236724 -0.141181 -0.080388 -0.026944 0.022261 0.072589 0.108213 0.157462 0.224338 0.349508 0.443299 0.534203 0.617445 0.709033 0.773782 0.816009 0.836758 0.818917 0.798666 0.774045 0.746846 0.736822 0.709670 0.668370 0.611440 0.519265 0.426691 0.332361 0.240893 0.136731 0.056144 -0.003649 -0.042086 -0.080826 -0.090862 -0.082380 -0.061356 -0.054307 -0.034863 -0.013472 0.005800 0.000000 0.000000 0.000000 interpolation : 0.020011 0.005800 -0.013472 -0.034863 -0.074317 -0.072955 -0.055436 -0.021135 0.007778 0.080625 0.161111 0.237868 0.318392 0.336664 0.312715 0.244677 0.117179 -0.004656 -0.134167 -0.255710 -0.334736 -0.414295 -0.459121 -0.466115 -0.416831 -0.371199 -0.308749 -0.236724 -0.141181 -0.080387 -0.026943 0.022261 0.072589 0.108213 0.157462 0.224338 0.349508 0.443299 0.534204 0.617445 0.709034 0.773782 0.816009 0.836759 0.818917 0.798667 0.774045 0.746847 0.736822 0.709670 0.668370 0.611441 0.519266 0.426692 0.332361 0.240893 0.136731 0.056144 -0.003648 -0.042086 -0.080825 -0.090862 -0.082379 -0.061355 -0.054306 -0.034863 -0.013471 0.005800 0.000001 0.000001 0.000001
J'ai ceci pour n=4.
Alors que je devraisavoir la même choseCitation:
avant interpolation :
0.020011 0.005800 -0.013472 -0.034863 -0.074317 -0.072955 -0.055436 -0.021135 0.007778 0.080625 0.161111 0.237868 0.318392 0.336664 0.312715 0.244677 0.117179 -0.004656 -0.134167 -0.255710 -0.334736 -0.414295 -0.459121 -0.466115 -0.416831 -0.371199 -0.308749 -0.236724 -0.141181 -0.080388 -0.026944 0.022261 0.072589 0.108213 0.157462 0.224338 0.349508 0.443299 0.534203 0.617445 0.709033 0.773782 0.816009 0.836758 0.818917 0.798666 0.774045 0.746846 0.736822 0.709670 0.668370 0.611440 0.519265 0.426691 0.332361 0.240893 0.136731 0.056144 -0.003649 -0.042086 -0.080826 -0.090862 -0.082380 -0.061356 -0.054307 -0.034863 -0.013472 0.005800 0.000000 0.000000 0.000000
interpolation :
0.020011 0.005800 -0.013472 -0.034863 -0.074317 -0.072955 -0.055436 -0.021135 0.007778 0.080625 0.161110 0.237867 0.318392 0.336664 0.312714 0.244676 0.117178 -0.004658 -0.134169 -0.255713 -0.334739 -0.414299 -0.459125 -0.466120 -0.416836 -0.371204 -0.308755 -0.236731 -0.141188 -0.080395 -0.026952 0.022252 0.072579 0.108202 0.157450 0.224326 0.349495 0.443285 0.534188 0.617429 0.709016 0.773764 0.815990 0.836739 0.818896 0.798644 0.774021 0.746822 0.736796 0.709643 0.668342 0.611411 0.519234 0.426659 0.332327 0.240858 0.136694 0.056106 -0.003688 -0.042127 -0.080868 -0.090906 -0.082426 -0.061403 -0.054356 -0.034914 -0.013525 0.005745 -0.000056 -0.000058 -0.000060
:scarymov:
Bien bien ... Reprenons ... Tu as un tableau que tu aimerais copier dans un autre c'est juste ... ?
Ton interpollation ... C'est quoi la dedans ... ?! Tu aimerais le même résultat avant et après interpollation ... C'est juste ... ?!
Montre le code qui effectue la copie ...
Et franchement ... Je vois pas bien ce que représente ton 'n' la-dedans ... 8O La taille de quoi ... ?
Il s'agit d'une interpollation. n corespond au nombre d'étages du filtre interpolation.
par exempele si on a le tableau suivant :
0 1 2 3 4 5 6
On demande à l'utilisateur le facteur d'interpolation: 4
on aura donc 0000 1111 2222 ....
Voici le .h
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 #ifndef _DVBT_SIGNAUXTESTS_H #define _DVBT_SIGNAUXTESTS_H /* ======== */ /* INCLUDES */ /* ======== */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <time.h> #include <sys/timeb.h> #include <unistd.h> /* =============== */ /* DEFINES / ENUMS */ /* =============== */ /* ========== */ /* STRUCTURES */ /* ========== */ typedef struct { int i; float* nacc; /*Accumulateur*/ float* diff; /*Differentiateur*/ float* prev; /*Valeurs précédentes*/ int stages; /*Nombre d'étages*/ } DVBTSignauxtests; /* ====================== */ /* PROTOTYPES / FUNCTIONS */ /* ====================== */ DVBTSignauxtests *CreateDVBTSignauxtests(); void FreeDVBTSignauxtests(DVBTSignauxtests *DS); void UseDVBTSignauxtests(DVBTSignauxtests *DS,int source_reelle[],int source_imaginaire[], int surechantillonage, int echantillon); float * UpsamplingDVBTSignauxtests(float sig[],int fact_surechantillon, int echantillon); float * conv(float *filtre,float *signal,int taille_entree,int taille_filtre); void FrequencyTransposition(float *signal_reel, float tk, int taille_signal); float * RaisedCosineSQRT(float nb_periodes,float nb_points,float roll_off); void ResetDVBTSignauxtests(DVBTSignauxtests *DS); float CicInterpolate(DVBTSignauxtests *DS, float in, int dump); void CicNum_stages(DVBTSignauxtests *DS, int n); #endif
Voivi le .c
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 /*------------------------------------------------------------------------------------------------*/ /* CIC interpolateur */ /*------------------------------------------------------------------------------------------------*/ printf("\nEntrez le Nombre d'étages du CIC :"); scanf("%d",&nombre_etages); printf("\nEntrez le Rapport d'interpolation :"); scanf("%d",&interp); taille_cic_interpolateur= ((int)((periodes*points+N*Ns-1)*interp)); float sortie_interp[taille_cic_interpolateur]; CicNum_stages(DS, nombre_etages); /*Initialisation de la structure du CIC en fonction du nombre d'étages*/ printf("\n"); printf("\navant interpolation :\n"); for(i=0;i<(periodes*points+N*Ns-1);i++) { printf(" %f",signal_re_conv_nyquist[i]); } printf("\n"); for (i=0;i<(periodes*points+N*Ns-1);++i) { interpolation=CicInterpolate(DS,signal_re_conv_nyquist[i],1); /*Utilisation du CIC Interpolation*/ sortie_interp[i*interp]=interpolation; for(j=1;j<interp;j++) { sortie_interp[j+interp*i]=interpolation; } } printf("\ninterpolation :\n"); for(i=0;i<(periodes*points+N*Ns-1)*interp;i++) { printf(" %f",sortie_interp[i]); }
avec signal_re_conv_nyquist[] d'une certaine taille qui change seloon l'utilisateur
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 void CicNum_stages(DVBTSignauxtests *DS, int n) { DS->stages = n; free(DS->nacc); free(DS->diff); free(DS->prev); DS->nacc=malloc(sizeof(int)*(n)); DS->diff=malloc(sizeof(int)*(n)); DS->prev=malloc(sizeof(int)*(n)); return; } float CicInterpolate(DVBTSignauxtests *DS, float in, int dump) { int i; if(dump) { DS->diff[0]=in-DS->prev[0]; DS->prev[0]=in; for(i=1;i<DS->stages;i++) { DS->diff[i]= DS->diff[i-1]-DS->prev[i]; DS->prev[i]=DS->diff[i-1]; } DS->nacc[0]+=DS->diff[DS->stages-1]; } for(i=0;i<(DS->stages-1);i++) { DS->nacc[i+1] += DS->nacc[i]; } // printf(" %f",DS->nacc[i]); return(DS->nacc[DS->stages-1]); }
qui donne :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 void interp(int *& tab, int & nb, int n) { int * newtab = (int*)malloc(sizeof(int)*nb*n); for(int i=0;i<nb;i++) { for(int j=0;j<n;j++) newtab[i*n+j] = tab[i]; } tab = newtab; nb = nb*n; } int main() { int nb = 4; int * tab = (int*)malloc(sizeof(int)*nb); for(int i=0;i<nb;i++) tab[i] = i; for(int i=0;i<nb;i++) printf("%d ", tab[i]); printf("\n"); interp(tab, nb, 4); for(int i=0;i<nb;i++) printf("%d ", tab[i]); printf("\n"); return 0; }
n = 4
0 1 2 3
0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3
Merci pour t'on aide mais ce n'est pa de la façon là que je veux.