I have written the equations to Proving Parseval's Relation but are giving me different answers Can you help?
Ältere Kommentare anzeigen
function sig_out=M1_3(f0,fs,dur,N)
clear all
close all
clc
if (nargin == 0)
fs=8000;
f0=25;
dur=1/f0;
N=[20];
end
f = zeros(1,N);%sets all values to 0 from 1 to N
a = zeros(1,N);%sets all values to 0 from 1 to N
p = zeros(1,N);%sets all values to 0 from 1 to N
for i= 1:2:N
f(i)=i*f0;
a(i)=4/(pi*i);
p(i)=pi/2;
end
sig_out=sumcos(f,a,p,fs,dur);
t = 0:1/fs:dur;
for j=1:2:N
%plot(j,(a(j)/N),'*');
%xlabel('K')
%ylabel('|X[k]/N|')
%title('Magnitude of line Spectrum of X[n] respectively')
%plot(j,(57.2957795*p(j)),'+');
%xlabel('K')
%ylabel('Phase of X[k] in degrees')
%title('Phase of line Spectrum of X[n] respectively')
%plot(j,(a(j)/N)^2,'d');
%xlabel('K')
%ylabel('(X[k]/N)^2')
%title('Power line Spectrum of discrete periodic signal X[n]')
hold on
end
hold off
%Trying to Prove Parseval's Relation
%from time signal directly
xn=sum(sig_out.*sig_out)/(length(sig_out))
%from power line spectrum
XK=(sum((a/N).^2))
1 Kommentar
Andrei Bobrov
am 31 Okt. 2011
what is it sumcos
Antworten (2)
Dr. Seis
am 31 Okt. 2011
Make sure the way you define things is consistent with the following definitions:
If:
- fs = sample rate (samples per second)
- N = number of samples
Then:
- dt = time increment (1/fs)
- df = frequency increment (fs/N)
- dur = duration of signal (1/df)
- t = time range (0:dt:(N-1)*dt)
- Nyq = Nyquist frequency (fs/2)
- f = frequency range (-Nyq:df:Nyq-df)
If you make sure that the way you define things in the time domain and frequency domain is consistent with the above definitions, then you should have no problem proving that the power in the time domain is equal to the power in the frequency domain.
Wayne King
am 31 Okt. 2011
Why not just use:
x = randn(1e3,1);
norm(x)
xdft = fft(x);
norm(xdft./sqrt(length(x)))
Kategorien
Mehr zu Fixed-Point Matrix Operations in MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!