Borrar filtros
Borrar filtros

Remove the negative frequency components of the signal.

7 visualizaciones (últimos 30 días)
Jackson
Jackson el 29 de Oct. de 2021
Comentada: Walter Roberson el 30 de Oct. de 2021
I want to remove the negative component of the signal(from -500 to 0) to make the negative half of the fft a flat line of 0 from -500 to 0 .
Fs=1000;
Ts=1/Fs;
t=0:Ts:10-Ts;
f1=50;f2=100;
y=2*cos(2*pi*t*f1)+ 4*cos(2*pi*t*f2);
N=length(y);
F=fft(y);
fr=(-N/2:N/2-1)*Fs/(N);
figure, plot(fr,abs(F))
xlabel(' frequency Hz')

Respuestas (1)

Walter Roberson
Walter Roberson el 29 de Oct. de 2021
Fs=1000;
Ts=1/Fs;
t=0:Ts:10-Ts;
f1=50;f2=100;
y=2*cos(2*pi*t*f1)+ 4*cos(2*pi*t*f2);
N=length(y);
F=fft(y);
Fsh = fftshift(F);
Fsh(1:floor(end/2)) = 0;
fr=(-N/2:N/2-1)*Fs/(N);
figure, plot(fr,abs(Fsh))
xlabel(' frequency Hz')
YL = ylim();
ylim([-1000 YL(2)]);
  2 comentarios
Jackson
Jackson el 30 de Oct. de 2021
If I want to change the y axis were the highest peak is at 0. Could I just subtract 20,000 from abs(Fsh), in the plot function line?
Walter Roberson
Walter Roberson el 30 de Oct. de 2021
Fs=1000;
Ts=1/Fs;
t=0:Ts:10-Ts;
f1=50;f2=100;
y=2*cos(2*pi*t*f1)+ 4*cos(2*pi*t*f2);
N=length(y);
F=fft(y);
Fsh = abs(fftshift(F));
Fsh(1:floor(end/2)) = 0;
Fsh = Fsh - max(Fsh);
fr=(-N/2:N/2-1)*Fs/(N);
figure, plot(fr,Fsh)
xlabel(' frequency Hz')
YL = ylim();
low = min(Fsh) * 1.1;
ylim([low, 1000])

Iniciar sesión para comentar.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by