Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear; clc; clf; close;
- f1 = 1000;
- f2 = 1400;
- fc = 100000; % 220000
- Fs = 8 * fc;
- N = 3200;
- n = 0 : N-1;
- m = 1; % m = [0, 0.25, 0.5, 1, 1.2];
- %x = 5*sin(2*pi * (f1/Fs) * n) + 0*sin(2*pi * (f2/Fs) * n);
- A = linspace(0, 1, 800);
- B = linspace(-1, 0, 800);
- x = [A B A B];
- x2n = x/max(abs(x));
- s = 10*(1 + m*x2n) .* cos(2*pi * fc/Fs * n);
- widmo = abs(fft(s));
- subplot(311), plot(n/N * Fs ,x), grid;
- subplot(312), plot(n/N * Fs, s, '-x'), grid; % sygnal zmodulowany
- subplot(313), stem(n/N * Fs, widmo, '-x'), grid;
- axis([0 Fs/2 0 max(widmo)]);
- figure;
- % znak = (1 + sign(s)) / 2;
- % swypr = s .* znak;
- %
- % [B, A] = butter(1,5000 / (Fs/2));
- % u = filter(B, A, swypr);
- % subplot(311), plot(n, u), grid;
- % subplot(312), plot(n, x), grid;
- % subplot(313), plot(n, swypr), grid;
- %znak = (1 + sign(s)) / 2;
- %swypr = s .* znak;
- [B, A] = butter(4, 5000 / (Fs/2));
- v = s .* cos(2*pi * fc/Fs * n);
- u = filter(B, A, v);
- subplot(311), plot(n, u), grid;
- subplot(312), plot(n, x), grid;
- %subplot(313), plot(n, swypr), grid;
Advertisement
Add Comment
Please, Sign In to add comment