How to create a rectangular pulse in time

I am trying to create a rectangular pulse to use an ideal low pass filter. I am going to multiply a function in the frequency domain by a pulse going up to 1 at 0, and ending at 10,000. I have tried using the rectpulse and rectangular pulse functions but have been unable to succescfully implement the pulse as a function of time. Could someone show me how to do this please?

 採用された回答

Image Analyst
Image Analyst 2017 年 7 月 30 日

0 投票

Lets say your audio spectrum is 20,000 elements long. You can make a pulse like this.
bandPassSignal = zeros(1, length(1, audioSpectrum)); % Initialize to all zeros.
bandPassSignal(1:10000) = 1; % First 10,000 elements are now 1.
% Now multiply by the spectrum of your audio signal:
filteredAudioSpectrum = audioSpectrum .* bandPassSignal;
% Now inverse fft and listen to the sound.
filteredTimeDomainSignal = ifft(filteredAudioSpectrum);
player = audioplayer(y, filteredTimeDomainSignal);
play(player);

1 件のコメント

Gage Haas
Gage Haas 2017 年 8 月 2 日
Would you mind looking at my attempt at this and see if you can tell me my error? https://www.mathworks.com/matlabcentral/answers/351201-ideal-audio-filter-with-pulse

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by