Fourier-Frequency analyse
显示 更早的评论
I need to do next: Draw a frequency image of following signal: t=0:0.0001:0.05; y=square(5*pi*50*t);
also it's required to draw real and imaginary part of frequency spectrum.
There is mine solution, so can anyone check it out
t=0:0.0001:0.05; y=square(5*pi*50*t); N=length(t); deltaf=1/0.05; f=(0:N-1)*deltaf;
disp('Efektivna vrijednost') Yef=sqrt(sum(y.*y)/N)
disp('Frekvencijska slika') F=(fft(y))*2/N;
figure, plot(f,F) axis([0 1200 -0.5 1])
figure, subplot(3,1,1)
plot(f,20*log10(real(F)/max(abs(F)))) axis([0 1200 -80 10])
subplot(3,1,2) plot(f,20*log10(imag(F)/max(abs(F)))) axis([0 1200 -80 10])
subplot(3,1,3) plot(f,20*log10(F/max(abs(F)))) axis([0 1200 -80 10])
采纳的回答
更多回答(3 个)
Dr. Seis
2012-1-20
You need to make a few changes:
If,
dt = 0.0001;
t = 0:dt:(0.05-dt);
N = length(t);
y_time = square(5*pi*50*t);
Then,
df = 1 / (N*dt);
Nyq = 1 / (2*dt);
f = -Nyq : df : Nyq-df;
y_freq = fftshift(fft(y_time))*dt;
Now you can plot the correct amplitudes with the correct frequencies:
plot(f,real(y_freq),'b-',f,imag(y_freq),'r-');
Robin Beene
2012-1-20
0 个投票
1 个评论
Dr. Seis
2012-1-20
Think of Parseval's theorem, the energy in the time domain is equal to the energy in the frequency domain. If this condition is not met, then it is a flag that something has gone wrong.
Robin Beene
2012-1-20
0 个投票
2 个评论
Dr. Seis
2012-1-20
To have just the y-axis plotted on logarithmic scale, try:
semilogy(f, imag(y_freq));
If you want just the x-axis plotted on logarithmic scale, then:
semilogx(f, imag(y_freq));
If you want x- and y-axis plotted on logarithmic scale, then:
loglog(f, imag(y_freq));
Robin Beene
2012-1-20
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with Signal Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!