How to draw a pulse train
이전 댓글 표시
I want to draw a pulse train in Matlab like the one shown blue in attached picture. The duration of each pulse is Tp and there are M=199 zeros in between two consective pulses. The PRI of the pulse train is 200Tp. Then I want to decompose each pulse into 7 small pulses of amplitude +1 and -1 (i.e., 1Tp=7Tc where Tc=28ns is the duration of small pulse) like shown white in the attached picture. 

답변 (1개)
Scott MacKenzie
2022년 3월 16일
편집: Scott MacKenzie
2022년 3월 17일
It seems you want to replace the negative portion of the pulse with zeros. Like this, perhaps:
fy=100;
wy=2*pi*fy;
duy=0.02;
fs=20000;
dt=1/fs;
t=-(duy-dt):dt:(duy-dt);
A=1.5;
y=A*square(wy*t);
subplot(1,2,1);
plot(t,y,'k')
axis([-duy duy -2.5 2.5])
xlabel('Seconds')
title('Square signal')
subplot(1,2,2);
y(y<0)=0;
plot(t,y,'k')
axis([-duy duy -2.5 2.5])
xlabel('Seconds')
title('Square signal')
댓글 수: 6
Sadiq Akbar
2022년 3월 17일
편집: Sadiq Akbar
2022년 3월 17일
Scott MacKenzie
2022년 3월 17일
tiledlayout was introduced in R2019b. You must be using an older version of MATLAB. I edited the code, substituting subplot for tiledlayout. It should work now.
As for your additional comment, the -ve pulse in my code was not replaced with a single zero. Each negative pulse has 100 zeros. Are you trying to stretch the -ve portion of the each pulse from 100 sample to 199 samples? Obviously, this would have be effect of creating a new waveform with a different period and different duty cycle.
Sadiq Akbar
2022년 3월 17일
편집: Sadiq Akbar
2022년 3월 17일
Scott MacKenzie
2022년 3월 17일
Sorry, not sure how to do that.
Sadiq Akbar
2022년 3월 17일
Scott MacKenzie
2022년 3월 17일
You're welcome. Good luck.
카테고리
도움말 센터 및 File Exchange에서 Pulse and Transition Metrics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
