Created
April 8, 2019 23:46
-
-
Save johnnyferreiradev/940a5ce3dad02e82a904c46852918b8e to your computer and use it in GitHub Desktop.
Transformada de Fourier
This file contains hidden or 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
clear all; | |
close all; | |
clc; | |
fs=1000; Ts=1/fs; | |
f1=20; | |
DigFreq1=2*pi*f1/fs; | |
f2=30; | |
DigFreq2=2*pi*f2/fs; | |
f3=40; | |
DigFreq3=2*pi*f3/fs; | |
N=1500; | |
n = 0:1:N-1; | |
t_sample = (0: Ts : (N-1)*Ts); | |
x=3.*cos(DigFreq1.*n+0.2) + cos(DigFreq2.*n-0.3) + 2.*cos(DigFreq3.*n+2.4); | |
figure; plot(t_sample, x) | |
X=fft(x); | |
X_mag=abs(X); | |
figure; | |
Fbin=0:1:N-1; | |
plot((fs/N).*Fbin, X_mag/(N/2)); | |
xlim([0 fs/2]) | |
set(gca, 'FontSize', 16) | |
xlabel('$f(Hz)$', 'Interpreter', 'LaTex', 'FontSize', 18); | |
ylabel('$|X(\omega)|$', 'Interpreter', 'LaTex', 'FontSize', 18); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment