
Simulating CTFT in MATLAB and calculating energy with Parseval's Theorem
Hi.
Would someone please review my MATLAB code and tell my where I'm messing
up? I want to simulate a continuous time signal and then apply Parseval's
Theorem for the continuous time FT. I'm simply using the rectangular
method to approximate integration. I've checked the values of Ex with
another program, and the results are close enough. The problem is that the
EX does not equal Ex. Is my formula for df wrong? If I substitute dt for
df in the last line EX equals Ex, but theoretically that is not the
correct
formula. The values for tf, dt, and f0 (I've tried several variations)
are
just test values they are not significant.
If anyone could help I'd appreciate it.
Yardley
tf = 13.2; % t final
dt = 1/5021; % continuous time infinitesimal delta t
t = dt*(0(tf/dt)1));
f0 = 433; %
x = sin(2*pi*f0*t);
Ex = sum((abs(x).^2)*dt) % area under abs(x).^2
L = length(t);
Nfft = 2^nextpow2(5*L);
X = fft(x, Nfft);
X = X/sqrt(Nfft); % CT FT is being simulated so we need to normalize X(.)
% to make it unitary because that is the form assumed
% for the CT Parseval equation
df = (1/dt)/Nfft;
EX = sum((abs(X).^2)*df) % this doesn't work, EX = sum((abs(X).^2)*dt)
does