fs = 1e3; % Sample frequency (Hz)
t = [0:1/fs:10]; % Time vector
x = 5*sin(2*pi*300.*t)+2*sin(2*pi*100.*t); % Signal
y = fft(x);
n = length(x); % number of samples
f = (0:n-1)*(fs/n); % frequency range
power = abs(y).^2/n; % power of the DFT
plot(f,power)
xlabel('Frequency')
ylabel('Power')
No comments:
Post a Comment