フィルターのクリア

Remove the negative frequency components of the signal.

7 ビュー (過去 30 日間)
Jackson
Jackson 2021 年 10 月 29 日
コメント済み: Walter Roberson 2021 年 10 月 30 日
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')

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 10 月 29 日
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 件のコメント
Jackson
Jackson 2021 年 10 月 30 日
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 2021 年 10 月 30 日
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])

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by