Created
July 26, 2017 03:29
-
-
Save stephenHartzell/2d12f18f888a792021e0a81bf21696d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fs = 10; % Sampling frequency | |
Ts = 1/Fs; % Sampling period | |
N = 128; % Total number of samples | |
n = 0:N-1; % Samples | |
t = Ts*(n); % Sampled times | |
fc1 = 1; % Frequency of first sinusoid | |
fc2 = 1.5; % Frequency of second sinusoid | |
y1 = cos(2*pi*fc1*t); % Discrete first sinusoid | |
y2 = cos(2*pi*fc2*t); % Discrete second sinusoid | |
y = y1+y2; % Total discrete signal | |
Y = fft(y); % The fft of the signal | |
df = 1/(N*Ts); % The frequency resolution | |
k = n; % Frequency spectrum samples | |
f = k*df; % Frequency values at the k samples | |
% Plot the useful fft of the signal with more samples | |
figure | |
stem(f,abs(Y)./N,'filled') | |
title('Useful Fourier Transform of y') | |
ylabel('Scaled |fft(y)|') | |
xlabel('frequency (Hz)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment