www.pudn.com > Theory-and-simulation-of-cazac.rar > cazac_gen.m, change:2009-12-20,size:991b


clc; 
clear all; 
N=128; 
M=N-1; 
can=[];%用来存放序列 
can1=[];%存放序列的绝对值 
uk_auto1=[];%存放自相关值 
sum1=[];%存放自己的和 
 
 for k=0:1:N-1 
  uk=exp((M*pi*k*k/N)*i); 
    uk_a=abs(uk); 
   can=[can,uk]; 
   can1=[can1,uk_a]; 
   end; 
f=fft(can); 
fx=f; 
for n=1:1:N 
    fx(n)=abs(f(n)); 
end 
for k=0:1:N-1 
    uk=exp((M*pi*k*k/N)*i); 
    sum=uk*conj(uk); 
end; 
sum1=[sum1,sum]; 
 
for m=1:1:N-1 
    uk=0; 
    ukm=0; 
    for k=0:1:N-m-1 
          uk=exp((M*pi*k*k/N)*i); 
          ukm=conj(exp((M*pi*(k+m)*(k+m)/N)*i)); 
          sum=sum+uk*ukm; 
    end; 
     
    for k=N-m:1:N-1 
          uk=exp((M*pi*k*k/N)*i); 
          ukm=conj(exp((M*pi*(k+m-N)*(k+m-N)/N)*i)); 
          sum=sum+uk*ukm; 
    end; 
    sum1=[sum1,sum]; 
end; 
sum1=sum1/N; 
k=0:1:N-1; 
%plot(k,can); 
%plot(k,can1); 
%plot(k,f) 
%plot(k,sum1); 
%plot(k,can,'o'); 
%plot(k,can1,'o'); 
%plot(k,fx,'-o',k,can,'->',k,f,'r'); 
%stem(can); 
plot(k,f); 
%stem(f); 
%grid on; 
%axis([0,N,-1.3,1.3]);