Periodic impulse train train
조회 수: 45 (최근 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:

댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!