x = cos(2*pi*150*t)+cos(2*pi*50*t);
y = x;
subplot(2,1,1)
plot(1000*t(1:50),y(1:50))
title('Signal')
xlabel('time (milliseconds)')
Y = fft(y,512);
Pyy = Y.* conj(Y) / 512;
f = 1000*(0:256)/512;
subplot(2,1,2)
plot(f,Pyy(1:257))
title('Frequency')
xlabel('frequency (Hz)')
댓글 달기