Borrar filtros
Borrar filtros

Periodic impulse train train

70 visualizaciones (últimos 30 días)
deji
deji el 11 de Nov. de 2011
Respondida: MD Rasel Basunia el 8 de Abr. de 2022
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

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 11 de Nov. de 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 comentarios
Abhishek Bhandari
Abhishek Bhandari el 8 de Abr. de 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
Fangjun Jiang el 11 de Abr. de 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);

Iniciar sesión para comentar.

Más respuestas (2)

mohit sharma
mohit sharma el 26 de Jun. de 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);

MD Rasel Basunia
MD Rasel Basunia el 8 de Abr. de 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:

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by