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 件のコメント

Sadiq Akbar
Sadiq Akbar 2022 年 3 月 16 日
I write a code that draws a square train. The code is as below:
clear all
clc
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);
plot(t,y,'k')
axis([-duy duy -2.5 2.5])
xlabel('Seconds')
title('Square signal')
Now I want to replace each -ve pulse with M=199 zeros. Can anyboy help me how to do that?

サインインしてコメントする。

回答 (1 件)

Scott MacKenzie
Scott MacKenzie 2022 年 3 月 16 日
編集済み: Scott MacKenzie 2022 年 3 月 17 日

0 投票

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
Sadiq Akbar 2022 年 3 月 17 日
編集済み: Sadiq Akbar 2022 年 3 月 17 日
Thank you very much dear Scott MacKenzie . I ran it but it gives me the following error:
Undefined function or variable 'tiledlayout'.
Error in RectangularpulseMathworks (line 11)
tiledlayout(1,2);
Also your given graph shows that -ve pulse is replaced by zero.But I want to replace every -ve pulse with M=199 zeros instead of a single zero.
Scott MacKenzie
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
Sadiq Akbar 2022 年 3 月 17 日
編集済み: Sadiq Akbar 2022 年 3 月 17 日
Thank you very much. Actually I want a waveform like given blue in the above picture. In this Tp is the pulse ON time. So we have one pulse of Tp duration where Tp= 1.9600e-07 seconds and then M=199 zeros, then one pulse of Tp duration and then M=199 zeros and so on. PRI is actually the time period of this periodic waveform.
Next I want to plot a 2nd plot but it is made from the 1st plot such that each pulse of 1st waveform is replaced with 7 small pulses shown in white colour in the above picture where each pulse is of duration Tc=2.8000e-08. And this 2nd plot should also be periodic.
Scott MacKenzie
Scott MacKenzie 2022 年 3 月 17 日
Sorry, not sure how to do that.
Sadiq Akbar
Sadiq Akbar 2022 年 3 月 17 日
ok Scott MacKenzie thank you very much. At least you tried your best to help me out. So thank you very much for your try and your good step for my help.
Scott MacKenzie
Scott MacKenzie 2022 年 3 月 17 日
You're welcome. Good luck.

サインインしてコメントする。

質問済み:

2022 年 3 月 15 日

コメント済み:

2022 年 3 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by