clc;clear all;close all;Tu=224e-6; T=Tu/2048; G=0;delta=G*Tu; Ts=delta+Tu; Kmax=2000; Kmin=0;FS=4096;q=10;fc=q*1/T;Rs=4*fc;t=0:1/Rs:Tu;M=Kmax+1;rand('state',0);a=-1+2*round(rand(M,1)).'+i*(-1+2*round(rand(M,1))).';A=length(a);info=zeros(FS,1);figure(1);stem(a );info(1:(A/2)) = [ a(1:(A/2)).'];info((FS-((A/2)-1)):FS) = [ a(((A/2)+1):A).'];carriers=FS.*ifft(info,FS);tt=0:T/2:Tu;figure(2);subplot(211);stem(tt(1:100),real(carriers(1:100)));title('subcar generation');subplot(212);stem(tt(1:500),imag(carriers(1:500)));figure(3);f=(1:(FS))/(FS);subplot(211);plot(f,abs(fft(carriers,FS)/FS));x=real(carriers);fs=4096/Tu;df=1/Tu;dalpha=2098/Tu;function [Sx, alphao, fo] =autofam(x, fs, df , dalpha)Np=pow2 (nextpow2 (fs/df ) ) ;L=Np/4;P=pow2 (nextpow2 (fs/dalpha/L))N=P*L;if length (x) <Nx(N)=0;elseif length (x) >Nx=x(l:N);endNN= (P-l) *L+Np;XX=X;Xx(NN)=0;xx=xx ( : );X=zeros (Np, P);for k=0:P-lX( : ,k+l) =xx(k*L+l:k*L+Np);enda=hamming (Np);XW=diag(a) *X;XW=X ;XFl=fft (XW);XFl=fftshift (XF1);XF1= [XF1(:,P/2+l:P) XF1(:,l:P/2) ];E= zeros (Np, P);for k=-Np/2:Np/2-lfor m=0:P-lE(k+Np/2+l,m+l) =exp(-i*2*pi*k*m*L/Np);endendXD=XF1.*E;XD=conj (XD' );XM=zeros (P,Np^2) ;for k=l:Npfor l=1:NpXM(:,(k-l)*Np+l)=(XD(:,k) .*conj(XD(:,1) ) );endendXF2=fft (XM);XF2=fftshift (XF2);XF2= [XF2(:,Np^2/2+l:Np^2 ) XF2(:,l:Np^2/2) ];XF2=XF2 (P/4 : 3*P/4 , : );M=abs (XF2);alphao=-l:l/N:l;fo=-.5:l/Np: .5;Sx=zeros (Np+1, 2*N+1)for kl=l: P/2+1for k2=l:Np^2if rem(k2,Np) ==0l=Np/2-l;elsel=rem(k2,Np) -Np/2-1;endk=ceil (k2/Np) -Np/2-1;p=kl-P/4-l;alpha= (k-1) /Np+ (p-1) /L/P;f=(k+l)/2/Np;if alpha<-l | alpha>lk2=k2+l;elseif f<-.5 | f> .5k2=k2+l;elsekk=1+Np*(f+.5);ll=1+N*(alpha+1);Sx(kk,ll) =M(kl,k2);endendend
MATLAB: This is the code for FFT Accumulation Method using autocorrelation.correct this code .we are receiving an error as Function definitions are not permitted in this context.
fft accumulation method
Related Question
- Removing the array elements
- Fast Fourier Transform of the subtraction between a signal and the same signal but shifted
- What’s going on about the code?? I used the same code the teammate used, but mine keep showing error
- How to add the solutions of xd as a matrix , I tried with xd1 , but it still give an error. and how can I make the new value as a initial value for the next st. x0 known and kmax =10. While the solution should be a matrix of 10 rows .. Thank you !
Best Answer