Fs = 128;
T = 1/Fs;
L = 256;
t = (0:L-1)*T;
x = 5 + 7*cos(2*pi*15*t - 30*pi/180) + 3*cos(2*pi*40*t - 90*pi/180);
y = x + randn(size(t));
figure;
plot(t,y)
title('noise')
xlabel('time(s)')
N = 2^nextpow2(L);
Y = fft(y,N)/N*2;
f = Fs/N*(0:1:N-1);
A = abs(Y);
P = angle(Y);
figure;
subplot(211);plot(f(1:N/2),A(1:N/2));
title('fuzhipinpu');
xlabel('pinlv(Hz)');
ylabel('fuzhi');
subplot(212);
plot(f(1:N/2),P(1:N/2));
title('xiangweipinpu');
xlabel('pinlv(Hz)');
ylabel('xiangwei');