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?

 Accepted Answer

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);

More Answers (0)

Categories

Find more on Audio Processing Algorithm Design in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!