Sie sind auf Seite 1von 9

%---------------- Signal Generator ------------------------------------

Fsampling = 4000; % Sampling frequency


T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*1000*t)+sin(2*pi*2000*t)+sin(2*pi*3000*t); %
figure;
plot(t,x);
title ('Original Signal');
%-----------------Fast Fourier Transform (FFT) -------------------------
n = 2^nextpow2(L);
Yfft = fft(x,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');

%---------------- Signal Generator ------------------------------------


Fsampling = 4000; % Sampling frequency
T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*1000*t)+sin(2*pi*5000*t)+sin(2*pi*10000*t); %
figure;
plot(t,x);
title ('Original Signal');
%-----------------Fast Fourier Transform (FFT) -------------------------
n = 2^nextpow2(L);
Yfft = fft(x,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');

%---------------- Signal Generator ------------------------------------


Fsampling = 22000; % Sampling frequency
T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*1000*t)+sin(2*pi*5000*t)+sin(2*pi*10000*t); %
figure;
plot(t,x);
title ('Original Signal');
%-----------------Fast Fourier Transform (FFT) -------------------------
n = 2^nextpow2(L);
Yfft = fft(x,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');
%---------------- Signal Generator ------------------------------------
Fsampling = 22000; % Sampling frequency
T = 1/Fsampling; % Sampling period
L = 500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*1000*t)+sin(2*pi*5000*t)+sin(2*pi*10000*t); %
figure;
plot(t,x);
title ('Original Signal');
%-----------------Fast Fourier Transform (FFT) -------------------------
n = 2^nextpow2(L);
Yfft = fft(x,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');
%---------------- Signal Generator ------------------------------------
Fsampling = 4200; % Sampling frequency
T = 1/Fsampling; % Sampling period
L = 500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*5*t)+sin(2*pi*20*t)+sin(2*pi*500*t)+sin(2*pi*2000*t); %
figure;
plot(t,x);
title ('Original Signal');
%-----------------Fast Fourier Transform (FFT) -------------------------
n = 2^nextpow2(L);
Yfft = fft(x,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');
%---------------- Signal Generator ------------------------------------
Fsampling = 4200; % Sampling frequency
T = 1/Fsampling; % Sampling period
L = 100; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*5*t)+sin(2*pi*20*t)+sin(2*pi*500*t)+sin(2*pi*2000*t); %
figure;
plot(t,x);
title ('Original Signal');
%-----------------Fast Fourier Transform (FFT) -------------------------
n = 2^nextpow2(L);
Yfft = fft(x,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');
Fsampling = 2000; % Sampling frequency T = 1/Fsampling;
T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*1000*t)+sin(2*pi*5000*t); % First row wave
figure;
plot(t,x);
title ('Original Signal');
Fsampling = 4000; % Sampling frequency
T = 1/Fsampling; % Sampling period
L = 500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*100*t)+sin(2*pi*1000*t); % First row wave
figure;
plot(t,x);
title ('Original Signal');

Fsampling = 3000; % Sampling frequency


T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*100*t)+sin(2*pi*1000*t); %
figure;
plot(t,x);
title ('Original Signal');
%-----------------Fast Fourier Transform (FFT) -------------------------
n = 2^nextpow2(L);
Yfft = fft(x,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');
%---------------- Signal Generator ------------------------------------
Fsampling = 1000; % Sampling frequency
T = 1/Fsampling; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
x = sin(2*pi*20*t)+sin(2*pi*100*t)+sin(2*pi*1000*t); %
figure;
plot(t,x);
title ('Original Signal');
%-----------------Fast Fourier Transform (FFT) -------------------------
n = 2^nextpow2(L);
Yfft = fft(x,n);
P2 = abs(Yfft/L);
P1 = P2(1:n/2+1);
P1(1:end-1) = 2*P1(1:end-1);
figure;
plot(0:(Fsampling/n):(Fsampling/2-Fsampling/n),P1(1:n/2));
title ('Frequency of the signal');

Das könnte Ihnen auch gefallen