# How to construct Polyphase (Frank) codes in MATLAB

I have written a piece of code in MATLAB to generate Frank codes - Pastebin link for pulse compression.

I know that Frank codes are stepped frequency approximations to Linear Frequency modulation(LFM).

LFM Parameters are obtained here:

PW = 100e-6;% Pulse Width
PCR = 100; % Pulse Compression Ratio
CPW = PW/PCR;% Compressed pulse width
Fm = 2/CPW; %Frequency sweep

• Stepped frequency approximation to LFM:
steppedFreq = 0:Fm/(N-1):Fm;
• The phase matrix is generated in the line:
Matrix = mod(Matrix*incPhi,360);
• Frank code is generated inside the for loop:
FCP = [FCP,exp(1j*(2*pift + Matrix(i,p)*pi/180))];
• The autocorrelation in dB is calculated here:
AutoCorrelationdB = 20*log10(abs(AutoCorrelation)/max(abs(AutoCorrelation)));

My question:

The Peak side lobe level obtained is only around $3.5\textrm{ dB}$. Am I following a correct method for generating Frank codes? The peak side lobe level is given by the formula 20*log10(1/(N*sin(pi/M))) as per the book Principles of Modern Radar: Basic Principles by M.A. Richards - Page 825 which is equal to $29\textrm{ dB}$ for my case($N = 100,M = 10$).

• MATLAB programming questions are off-topic for this site. Please ask the moderators to migrate this to stackoverflow.SE or another SE site for programming questions. – Dilip Sarwate Aug 28 '14 at 11:41
• I believe that this question has enough of DSP in it, to be answered on DSP SE (we do not lack great programmers here). – jojek Aug 28 '14 at 12:44
• Plot of the ACF shows lots of ripples (which you seem to be interpreting as side-lobes). Looking at plot(real(FCP)) and plot(imag(FCP)) shows a lot of phase discontinuities which is probably partly responsible for the ripples. Though am I still getting strong peaks (not ripples) when removing those phase discontinuities (maybe I did something wrong, perhaps someone would have better luck there, or at least be able to explain why those peaks are there). – SleuthEye Aug 28 '14 at 13:42
• It looks like you've incorporated parts of the Answer to your code in PasteBin, right? Either way, thanks for making the code available, nice implementation in Matlab. – Milliarde Mar 10 '16 at 22:22

% created by MUSTAFA SAMI AHMED
% Email mustafa_sami87@yahoo.com
clc;
clear all;
M =100;
L=sqrt(M);
bv = 0:L-1;
Matrix = bv'*bv ;
% alfa= (4*pi)/(L);

% Matrix_new = alfa*Matrix;
incPhi = (2*pi)/L; %incremental phase change
Matrix = mod(Matrix*incPhi,2*pi);

b=reshape(Matrix,1,[]); % matrix 1D size 1xM
for p = 1:M
d(p) = exp(1j*b(p)) ;
end

AutoCorrelation = xcorr(d);

AutoCorrelationdB =10*log10(abs(AutoCorrelation)/max(abs(AutoCorrelation)));
figure(1);
stem(b);
%   x=wden(AutoCorrelationdB,'heursure','h','mln',10,'sym10');
%x=wiener2(AutoCorrelationdB, [3 80 ]);
figure(2);
plot((AutoCorrelationdB));

• And what is that? – jojek May 26 '15 at 11:22