Effacer les filtres
Effacer les filtres

Remove the negative frequency components of the signal.

7 vues (au cours des 30 derniers jours)
Jackson
Jackson le 29 Oct 2021
Commenté : Walter Roberson le 30 Oct 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')

Réponses (1)

Walter Roberson
Walter Roberson le 29 Oct 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 commentaires
Jackson
Jackson le 30 Oct 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 le 30 Oct 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])

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by