Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement