Subversion Repositories svnkaklik

Rev

Rev 537 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

Rev 537 Rev 542
Line 9... Line 9...
9
#define SIGNAL_SAMPLES  SAMPLES*20
9
#define SIGNAL_SAMPLES  SAMPLES*20
10
 
10
 
11
int sample[SAMPLES];
11
int sample[SAMPLES];
12
int signal[SIGNAL_SAMPLES];
12
int signal[SIGNAL_SAMPLES];
13
 
13
 
14
double correlation[SIGNAL_SAMPLES];
14
long int correlation[SIGNAL_SAMPLES];
15
 
15
 
16
int obdelnik(int *pole, int delka_pole, int delka_pulsu, int spozdeni) //generuje testovaci lichobeznikovy puls  do zadaneho pole
16
int obdelnik(int *pole, int delka_pole, int delka_pulsu, int spozdeni) //generuje testovaci lichobeznikovy puls  do zadaneho pole
17
{
17
{
18
int i;
18
int i;
19
int value=0;
19
int value=0;
20
  for (i=0; i <= delka_pole; i++) { 
20
  for (i=0; i <= delka_pole; i++) { 
21
    if (i < spozdeni && i < delka_pole) pole[i]=value;
21
    if (i < spozdeni && i < delka_pole) pole[i]=value;
22
 
22
 
23
    if ((i > spozdeni) && (i < (spozdeni+10))) pole[i] = value++;
23
    if ((i > spozdeni) && (i <= (spozdeni+10))) pole[i] = value++;
24
 
24
 
25
    if (i < (spozdeni+delka_pulsu+10) && i > (spozdeni+10) && i < delka_pole) pole[i]= value;      
25
    if (i < (spozdeni+delka_pulsu+10) && i > (spozdeni+10) && i < delka_pole) pole[i]= value;      
26
 
26
 
27
    if (i < (spozdeni+delka_pulsu+19) && i > (spozdeni+delka_pulsu+10) && i < delka_pole) pole[i] = value--;      
27
    if (i <= (spozdeni+delka_pulsu+19) && i > (spozdeni+delka_pulsu+9) && i < delka_pole) pole[i] = value--;      
28
 
28
 
29
    if (i > (spozdeni+delka_pulsu+19) && i < delka_pole) pole[i]=value;
29
    if (i > (spozdeni+delka_pulsu+19) && i < delka_pole) pole[i]=value;
30
  }
30
  }
31
}
31
}
32
 
32
 
Line 37... Line 37...
37
static const float k = 0.0001;
37
static const float k = 0.0001;
38
 
38
 
39
int t;
39
int t;
40
float ble;
40
float ble;
41
  if((spozdeni+delka_pulsu) < delka_pole)
41
  if((spozdeni+delka_pulsu) < delka_pole)
42
    for(t=0;t < delka_pulsu;t++) pole[spozdeni+t] = round ( 100*sin(2*pi*t*(f0+(k/2)*t)) );
42
    for(t=0;t < delka_pulsu;t++) pole[spozdeni+t] = floor( 100*sin(2*pi*t*(f0+(k/2)*t)) );
43
  else return 0;
43
  else return 0;
44
 
44
 
45
}
45
}
46
 
46
 
47
int exp_chirp(int *pole, int delka_pole, int delka_pulsu, int spozdeni){  // vygeneruje linearni chirp a vzorky ulozi do pole
47
int exp_chirp(int *pole, int delka_pole, int delka_pulsu, int spozdeni){  // vygeneruje linearni chirp a vzorky ulozi do pole
Line 51... Line 51...
51
static const float k = 0.0001;
51
static const float k = 0.0001;
52
 
52
 
53
int t;
53
int t;
54
float ble;
54
float ble;
55
  if((spozdeni+delka_pulsu) < delka_pole)
55
  if((spozdeni+delka_pulsu) < delka_pole)
56
    for(t=0;t < delka_pulsu;t++) pole[spozdeni+t] = round ( 100*sin(2*pi*t*(f0+(k/2)*t)) );
56
    for(t=0;t < delka_pulsu;t++) pole[spozdeni+t] = floor ( 100*sin(2*pi*t*(f0+(k/2)*t)) );
57
  else return 0;
57
  else return 0;
58
 
58
 
59
}
59
}
60
 
60
 
61
 
61
 
62
int main (void)
62
int main (void)
63
{
63
{
64
   int i,n,m,delay;
64
   int i,n,m,delay;
65
   double r;
65
   long int r;
66
	FILE *out;
66
	FILE *out;
67
 
67
 
68
   obdelnik(sample,SAMPLES,100,0);			// vyrobi vzorek signalu
68
   linear_chirp(sample,SAMPLES,200,0);			// vyrobi vzorek signalu
69
   obdelnik(signal,SIGNAL_SAMPLES,100,1100);			// vyrobi signal ve kterem se vzorek hleda
69
   linear_chirp(signal,SIGNAL_SAMPLES,200,500);			// vyrobi signal ve kterem se vzorek hleda
70
 
70
 
71
   for(n=0; n < (SIGNAL_SAMPLES - SAMPLES);n++){			//spocita korelaci pro mozna spozdeni
71
   for(n=0; n < (SIGNAL_SAMPLES - SAMPLES);n++){			//spocita korelaci pro mozna spozdeni
72
     r=0;
72
     r=0;
73
     for(m=0;m < SAMPLES;m++) r += sample[m]*signal[m+n];
73
     for(m=0;m < SAMPLES;m++) r += sample[m]*signal[m+n];
74
     correlation[n]=r;
74
     correlation[n]=r;
Line 86... Line 86...
86
   for(i=0;i< SIGNAL_SAMPLES;i++)
86
   for(i=0;i< SIGNAL_SAMPLES;i++)
87
   {
87
   {
88
//     fprintf(stdout,"%3u ",i);	 		// vypise cislo bunky v poli (spozdeni)
88
//     fprintf(stdout,"%3u ",i);	 		// vypise cislo bunky v poli (spozdeni)
89
 //    fprintf(stdout,"%2i ",sample[i]);
89
//     fprintf(stdout,"%2i ",sample[i]);
90
//     fprintf(stdout,"%2d ",signal[i]);
90
//     fprintf(stdout,"%2d ",signal[i]);
91
     fprintf(out,"%3.2f\n",correlation[i]);		// vypise hodnotu korelace nejvissi cislo je nejvetsi korelace.
91
     fprintf(out,"%d %d %d %ld \n",i,sample[i], signal[i], correlation[i]);		// vypise hodnotu korelace nejvissi cislo je nejvetsi korelace.
92
   }
92
   }
93
   fprintf(stdout,"\nvzorek v signalu zacina na miste: %3u \n",delay);
93
   fprintf(stdout,"\nvzorek v signalu zacina na miste: %3u \n",delay);
94
	fclose(out);
94
	fclose(out);
95
  exit(1);
95
  exit(1);
96
}
96
}