# Find Syncword (pattern) in signal, using Correlation

I have a signal which always has the same syncword ([93 0b 51 de] in hexa).

I also have a signal with additive noise(attacing it, and I want to find my syncword in that a noisy signal using corelation(actually using xcross corelation), I attach the plot of my signal with additive noise(actually the demodulated signal that I de modulated it), my syncword is hidden here with noised signal and other data(like crc ..but doesn't matter for me and Im just looking for my syncword) those data Im getting from transmitter that's transmiting on frequency 868MHZ , Im implicitly the receiver and sampling in frequency 868MHz , those IQ samples data has packets and Im seeing them on my matlab those IQ samples data(sampling them on 20480000) I demodulated them by two matched filters and the data the I got is ranges between 1 , -1 . -1 means 0 in binary and 1 means 1 in binary.. (the plot of my demodulated data see the first photo that I attached above..

code in matlab:

>>fs=204800;
>>dk=loadFile('fm.dat'); %Im loading the IQ samples that I sampled them by my hardware sampler , once I do plot(real(dk)) I see the packets in matlab

>> t20=[-40000:40000]*(1/fs);
>> mf1200 = 100*exp(i*2*pi*t20*100000);
>> mf2200 = 100*exp(i*2*pi*t20*-100000);
>> d12 = conv(dk,mf1200,'same');
>> d22 = conv(dk,mf2200,'same');
>> ddif=((abs(d12)-abs(d22))./(abs(d12)+abs(d22)));
>> xCorrResult=xcorr(ddif',random);


Then I used xcorr, but I was a little confused by that. Can you help me? It looks like that signal was too noisy so that no syncword was found in my demodulated data that ranges between (-1 1) ? the packet that I transmit is in frequency 868MHZ, 50KHZ symbol rate , deviation 100KHZ , and my syncword/data are attached in the photo below: the file can be opened on matlab by this matlab code (plot(real(y) will give you plot of packets like nullPacketDatanullPacketDatanullPacketData):

function y = loadFile(filename)
%

% reads  complex samples from the rtlsdr file
%

fid = fopen(filename,'rb');