Periodic impulse train train
95 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
deji
le 11 Nov 2011
Réponse apportée : MD Rasel Basunia
le 8 Avr 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
0 commentaires
Réponse acceptée
Fangjun Jiang
le 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 commentaires
Abhishek Bhandari
le 8 Avr 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
le 11 Avr 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);
Plus de réponses (2)
mohit sharma
le 26 Juin 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 commentaires
MD Rasel Basunia
le 8 Avr 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/957860/image.png)
0 commentaires
Voir également
Catégories
En savoir plus sur Digital Filtering dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!