Periodic impulse train train
94 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Fangjun Jiang
2011-11-11
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 个评论
Abhishek Bhandari
2018-4-8
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
2018-4-11
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);
更多回答(2 个)
mohit sharma
2019-6-26
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 个评论
MD Rasel Basunia
2022-4-8
%% 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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filtering 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!