Subversion Repositories svnkaklik

Rev

Rev 536 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 536 Rev 537
Line 14... Line 14...
14
double correlation[SIGNAL_SAMPLES];
14
double 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=1;
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+20) && i > (spozdeni+delka_pulsu+10) && i < delka_pole) pole[i] = value--;      
27
    if (i < (spozdeni+delka_pulsu+19) && i > (spozdeni+delka_pulsu+10) && i < delka_pole) pole[i] = value--;      
28
 
28
 
29
    if (i > (spozdeni+delka_pulsu+20) && 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
 
33
int linear_chirp(int *pole, int delka_pole, int delka_pulsu, int spozdeni){  // vygeneruje linearni chirp a vzorky ulozi do pole
33
int linear_chirp(int *pole, int delka_pole, int delka_pulsu, int spozdeni){  // vygeneruje linearni chirp a vzorky ulozi do pole
34
 
34
 
Line 63... Line 63...
63
{
63
{
64
   int i,n,m,delay;
64
   int i,n,m,delay;
65
   double r;
65
   double r;
66
	FILE *out;
66
	FILE *out;
67
 
67
 
68
   linear_chirp(sample,SAMPLES,100,0);			// vyrobi vzorek signalu
68
   obdelnik(sample,SAMPLES,100,0);			// vyrobi vzorek signalu
69
   linear_chirp(signal,SIGNAL_SAMPLES,500,1000);			// vyrobi signal ve kterem se vzorek hleda
69
   obdelnik(signal,SIGNAL_SAMPLES,100,1100);			// 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 80... Line 80...
80
       delay = n;
80
       delay = n;
81
       r = correlation[n];
81
       r = correlation[n];
82
     }
82
     }
83
   }
83
   }
84
 
84
 
85
   out=fopen("output.txt",'w');
85
   out=fopen("./output.txt","w");
86
   for(i=0;i<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,"%3.2f\n",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
}