How to generate an impulse sequence

50 views (last 30 days)
I want to generate an impulse sequence or a train of impulse with a frequency of 1.6 Hz with matlab. How can I do that?

Accepted Answer

Image Analyst
Image Analyst on 1 Dec 2013
You could create a comb function like this:
% Create 1 second long signal of all zeros.
% Each time element is defined to be 0.000125 second long.
t = zeros(1, 5*1600);
% Create impulses every 0.000625 seconds.
% That would mean it occurs every 5th sample
t(1:4:end) = 1
Of course you can decide however many elements you want to be in a one second span and how narrow your pulses are.
  3 Comments
Image Analyst
Image Analyst on 2 Dec 2013
It's simply just an array. How you interpret it is up to you. If you want it in Hz, fine, it's in Hz. If you want it in the frequency domain, fine, it's in the frequency domain. Nothing to do at all except in how you interpret it - the array can stay the same, it's just that the meaning of one element to the next means some thing different. It's in seconds or milliseconds, or in Hz or whatever. It's however you want to interpret it.
ismail ismail
ismail ismail on 31 Jan 2021
How to generate a signal Dirac (t-3) using Zeros function Matlab

Sign in to comment.

More Answers (1)

MD Rasel Basunia
MD Rasel Basunia on 8 Apr 2022
%% Creating a impulse train
f=10;% frequency of impulse
fs=4*f;% sampling frequency with oversampling factor
Ts=1/fs;% sampling interval or period
t=-25:Ts:25;% Time range for impulse train
% creating impulse function
x=@(t) (t==0)
%% Method 1
xshift = x(t)+x(t-1)+ x(t+1)+x(t-2)+x(t+2);
subplot(311)
stem(t,xshift,'^','linewidth',2);grid on;ylim([0 2]);
xlabel('Time(sec)');ylabel('Amplitude');
title('shifted impulse with origin');
%% Method 2
xshift = @(t) x(t)+ x(t-1)+x(t+1)+x(t-2)+x(t+2)
subplot(312)
stem(t,xshift(t),'r','^','linewidth',2);grid on;
xlabel('Time(sec)');ylabel('Amplitude');
title(' Using Annonimous function');ylim([0 2]);
%% impulse train
sum=zeros(size(t))
for k = -25:25
sum = sum+x(t-k)
end
subplot(313)
stem(t,sum,'^','linewidth',2);grid on;xlabel('Time(sec)');
ylabel('Amplitude');
title('Impulse Train ');ylim([0 2]);
%% completed
%% Output :

Community Treasure Hunt

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

Start Hunting!