Forums

Cross Correlation Plot

Started by schira October 2, 2010
I have to plot the cross correlation Ryx with respect to Doppler shift and
Lag in the following code, in a 3D graph using mesh command in Matlab. I
tried many ways but none of them worked and just gave me errors. Can anyone
please guide me? 

%
%Joint estimation of delay and Doppler shift
%
fd = (-.1:.01:.1)*fp; %Doppler shift range
Nd = length(fd); %Number of Doppler shifts
K = 4; %interpolation factor
Ryx = zeros(Nd,K*(L-M)); %Correlation matrix
Y = fft(y); %FFT of y(n)
for i = 1:Nd
alp = (fp + fd(i))/fp; %compute alpha
Md = floor(M/alp); %modified pulselength
x = [A*sin(2*pi*fp*alp*[0:Md-1]), zeros(1,L-Md)]; %Doppler shifted pulse
X = fft(x); %FFT of x(alpha n)
XY = Y .* conj(X); %Y(k)X*(k)
XYzp = [XY(1:L/2),zeros(1,(K-1)*L),XY(L/2+1:L)]; %zero-padded Y(k)X*(k)
ryxKL = ifft(XYzp); %inverse FFT
Ryx(i,:) = ryxKL(1:K*(L-M)); %cross-correlation
end
absRyx = abs(Ryx);
%Find maximum cross-correlation over Doppler shift and lag
mx = 0;
for i = 1:Nd
[xx,j] = max(absRyx(i,:));
if xx>mx
mx = xx;
rm = i; %Doppler shift
cm = j; %lag
end
end
%Doppler shift and time delay estimates
Doppler_shift_est = fd(rm)
Delay_est = cm-1

How should I use the mesh and surface command to plot cross-correlation
versus lag and doppler shift? 


schira wrote:
>I have to plot the cross correlation Ryx with respect to Doppler shift
and
>Lag in the following code, in a 3D graph using mesh command in Matlab. I >tried many ways but none of them worked and just gave me errors. Can
anyone
>please guide me? >[...] > >How should I use the mesh and surface command to plot cross-correlation >versus lag and doppler shift? >
mesh and/or surf tend to be a bit of a pain. If your problem is with plotting, there is no need to post the code that runs your simulation. Instead, post zeros(N,M) or whatever for your Z coordinate, as well as how you're trying to generate your grid and call those functions. And then post the exact messages. Usually it amounts to swapping the arguments to the functions until it works, and trying the transposition operator in a few places (or just reading the help). And you might be better off posting in a MATLAB group if I'm understanding your question correctly.