Subversion Repositories svnkaklik

Rev

Rev 523 | Rev 525 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int sample[100];
int signal[500];

double correlation[1000];

int obdelnik(int *pole, int delka_pole, int delka_pulsu, int spozdeni) //generuje testovaci lichobeznikovy puls  do zadaneho pole
{
int i;
int value=1;
  for (i=0; i <= delka_pole; i++) { 
    if (i < spozdeni && i < delka_pole) pole[i]=value;

    if ((i > spozdeni) && (i < (spozdeni+10))) pole[i] = value++;

    if (i < (spozdeni+delka_pulsu+10) && i > (spozdeni+10) && i < delka_pole) pole[i]= value;      

    if (i < (spozdeni+delka_pulsu+20) && i > (spozdeni+delka_pulsu+10) && i < delka_pole) pole[i] = value--;      

    if (i > (spozdeni+delka_pulsu+20) && i < delka_pole) pole[i]=value;
  }
}

int main (void)
{
   int i,n,m;
   double r;

   obdelnik(sample,100,10,35);                  // vyrobi vzorek signalu
   obdelnik(signal,500,10,100);                 // vyrobi signal ve kterem se vzorek hleda

   for(n=0; n < 400;n++){                       //spocita korelaci pro mozna spozdeni
     r=0;
     for(m=0;m < 100;m++) r += sample[m]*signal[m+n];
     correlation[n]=r;
   }


   for(i=0;i<400;i++)
   {
     fprintf(stdout,"%3u ",i);                  // vypise cislo bunky v poli (spozdeni)
//     fprintf(stdout,"%2d ",sample[i]);
//     fprintf(stdout,"%2d ",signal[i]);
     fprintf(stdout,"%3.2f\n",correlation[i]);          // vypise hodnotu korelace nejvissi cislo je nejvetsi korelace.
   }

  exit(1);
}