Strange disagreement between analytical phase and unwrap(angle())
Show older comments
I consider a simple pulse sequence composed of four discete pulses that start at sampel
and include
zeros interleaved between the pulses:

Matlab uses the following convention for the discrete Fourier Tranform in function fft.m:
I compute this by hand:

using the Dirichlet kernel to simplify the expression for the amplitude and phase; here
,
,
, and
. I'd like to numerically compute the amplitude and phase of my analytic solution with Matlab's output. I need to understand the discprepancy between Matlab's output phase and the analytical version
; I emphasize that the "analytical" version is the discrete Fourier transform version, using the Matlab convention. The following code shows that the fourier domain signal appears to agree with my solution (above), but that the phase output by Matlab, separately, does not:
%Time series parameters
L = 4;%number of pulses
dn = 20;%zeros between pulses
N = 400;%total length of time series
n0 = 2^4;%first non-zero pulse
Ampl = 15; %pulse sequence amplitude
%Define signal and it's spectral form
k = 1:N;
k = k(:);
signal = zeros(N,1);
ind = n0 + dn*(0:(L-1)); %non-zero pulse indices
signal(ind) = Ampl; %asign at non-zero pulse indices
Xk = fft(signal); %fft of signal using convention I wrote above
%compare MATLAB output to analytical solutions
%MATLAB ampltiude and phase
absXk = abs(Xk); %magnitude of signal
phiXk = unwrap(angle(Xk)); %phase of signal
%analytical amplitude and phase
Xkabs = abs( Ampl*sin((pi*L/N)*(k-1)*dn)./sin((pi/N)*(k-1)*dn) ); %magnitude above
Xkabs(1) = Ampl*L; %divide by zero correction
Xkphi = -(2*pi/N)*(k-1)*(n0 - 1 + 1/2*(L-1)*dn); %analytical phase term from equation above
%Compare amplitude (they match)
figure;
plot(k, absXk,'-k','linewidth',6); hold on;
plot(k, Xkabs,'--r','linewidth',2);
title('Compare Amplitude Spectrum'); %Checks!
axis square;
%Compare phase (they do not match)
figure;
plot(k, phiXk, '-k','linewidth',6); hold on;
plot(k, Xkphi,'--r','linewidth',4);
title('Compare Phase'); %Disagreement
axis square;
%Compare total signals (they match)
figure;
plot(Xk,'-k','linewidth',6); hold on;
plot(Xkabs.*exp(1j*Xkphi),'-r','linewidth',2); hold on;
title('Compare Complex Signals'); %Agreement
axis square;
The three figures from each plot illustrate the issue with unwrap( angle ( ) ), which I show below. I'm unclear what the problem is. Is it circularity in the phase? I require that the phase output by Matlab can be modified to agree with a model.
Thank you.
Amplitude, phase, and total signal shown in order:


Signal:

Accepted Answer
More Answers (0)
Categories
Find more on Communications Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!