Periodic impulse train train
118 views (last 30 days)
Show older comments
hi, how can i generate a periodic impulse train with each impulse having a unit amplitude and 1 sample in width with a sampling frequency fs and 1second in length. thank u very much in advance
0 Comments
Accepted Answer
Fangjun Jiang
on 11 Nov 2011
f=10; %frequency of the impulse in Hz
fs=f*10; % sample frequency is 10 times higher
t=0:1/fs:1; % time vector
y=zeros(size(t));
y(1:fs/f:end)=1;
plot(t,y);
3 Comments
Abhishek Bhandari
on 8 Apr 2018
I want to define impulse train from -1 to 1.Please correct my code.
f=1/T; %frequency of the impulse in Hz
fs=f*2*pi; % sample frequency is 10 times higher
t1=0:1/fs:1 % time vector
t2 = 0: -1/fs:-1
t=[t1 t2]'
y=zeros(size(t));
y(1:fs/f:end)=1
plot(t,y);
Fangjun Jiang
on 11 Apr 2018
f=1/T; %frequency of the impulse in Hz
fs=f*10; % sample frequency is 10 times higher
t=-1:1/fs:1 % time vector
y=zeros(size(t));
y(1:fs/f:end)=1
plot(t,y);
More Answers (2)
mohit sharma
on 26 Jun 2019
f=1/T; %frequency of the impulse in Hz
fs=f*2*pi; % sample frequency is 10 times higher
t1=0:1/fs:1 % time vector
t2 = 0: -1/fs:-1
t=[t1 t2]'
y=zeros(size(t));
y(1:fs/f:end)=1
plot(t,y);
0 Comments
MD Rasel Basunia
on 8 Apr 2022
%% Here impulse train or dirac comb function
%% 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:
0 Comments
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!