Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- N = 1000;
- fs = 400;
- t = 0:1/fs:(N-1)/fs;
- f1 = 20;
- f2 = 70;
- f3 = 150;
- A1 = 2;
- A2 = 1;
- A3 = 4;
- phi1 = 0;
- phi2 = pi/4;
- phi3 = pi/6;
- n = randn(1,1000);
- x1 = A1*sin(2*pi*f1*t + phi1);
- x2 = A2*sin(2*pi*f2*t + phi2);
- x3 = A3*sin(2*pi*f3*t + phi3);
- x = x1+x2+x3;
- SNR = max(x)/5;
- noise = mod(n,SNR);
- subplot(3,1,1), plot(t,x+noise);
- xlabel('czas [t]');
- ylabel('x(t)')
- y = fft(x);
- m = 20*log10(abs(y));
- p = unwrap(angle(y));
- f = 0:fs/N:fs - fs/N;
- %index = (1:fs);
- subplot(3,1,2), plot(f,m); %wykres amplitudy
- ylabel('modul amplitudy'), grid on
- subplot(3,1,3), plot(f,p*180*pi); %faza
- ylabel('faza [stopnie]'), grid on
- xlabel('Czestotliwosc [Hz]')
- clear all;
- clc;
- %********************************************************************
- N = 300;
- fs = 1500;
- t = 0:1/fs:(N-1)/fs;
- f1 = 120;
- f2 = 127;
- f3 = 250;
- A1 = 2;
- A2 = 1;
- A3 = 4;
- phi1 = 0;
- phi2 = pi/4;
- phi3 = pi/6;
- n = randn(1,N);
- x1 = A1*sin(2*pi*f1*t + phi1);
- x2 = A2*sin(2*pi*f2*t + phi2);
- x3 = A3*sin(2*pi*f3*t + phi3);
- x = x1+x2+x3;
- SNR = x.^2/(35*20*log10(abs(n)));
- noise = mod(n,SNR);
- subplot(3,1,1), plot(t,x+noise);
- xlabel('czas [t]');
- ylabel('x(t)')
- y = fft(x);
- m = 20*log10(abs(y));
- p = unwrap(angle(y));
- f = 0:fs/N:fs - fs/N;
- %index = (1:fs);
- subplot(3,1,2), plot(f,m); %wykres amplitudy
- ylabel('modul amplitudy'), grid on
- subplot(3,1,3), plot(f,p*180*pi); %faza
- ylabel('faza [stopnie]'), grid on
- xlabel('Czestotliwosc [Hz]');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement