rectangle pulse start from (0,0) in matlab

2 ビュー (過去 30 日間)
nune pratyusha
nune pratyusha 2020 年 12 月 16 日
コメント済み: Abhishek Gupta 2020 年 12 月 22 日
Fs = 1e9;
t = 0:1/Fs:(4*1200e-9);
pulsewidth = 200e-9;
pulseperiods =[0:4]*1200e-9;
x = pulstran(t,pulseperiods,@rectpuls,pulsewidth);
plot(t,x)
  2 件のコメント
Abhishek Gupta
Abhishek Gupta 2020 年 12 月 21 日
Hi,
Can you elaborate your question?
nune pratyusha
nune pratyusha 2020 年 12 月 22 日
Fs = 1e9;
t = 0:1/Fs:(4*1200e-9);
pulsewidth = 200e-9;
pulseperiods =[0:4]*1200e-9;
x = pulstran(t,pulseperiods,@rectpuls,pulsewidth);
plot(t,x)
for this code at t=0 the value of x=1 i.e rectangular pulse is starting from 1 but i want for t=0 the pulse also starting from 0 i.e x=0

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

回答 (1 件)

Abhishek Gupta
Abhishek Gupta 2020 年 12 月 22 日
Hi,
As per my understanding, you want to create a rectangular pulse with x=0 at t=0. The reason behind why you are not getting x=0 at t=0 is that you have mentioned pulseperiods = [0 0.12 0.24 0.36 0.48], which means the first pulse will be at x=0 with x=pulsewidth/2 at t=0.
One possible workaround would be to start the pulse from x=0 by offsetting the pulse period with (pulsewidth/1.999). Note that if you would shift by exactly (pulsewidth/2) then you would get x=1 at t=0. To avoid the same, it would be preferrable to offset by a number slightly greater than half of the pulsewidth.
The implementation would look something like this: -
Fs = 1e9;
t = 0:1/Fs:(4*1200e-9);
pulsewidth = 200e-9;
pulseperiods = [0:4]*1200e-9 + pulsewidth/1.999;
x = pulstran(t,pulseperiods,@rectpuls,pulsewidth);
plot(t,x);
Output pulse:-
  2 件のコメント
nune pratyusha
nune pratyusha 2020 年 12 月 22 日
Thank you Sir
Abhishek Gupta
Abhishek Gupta 2020 年 12 月 22 日
Accept the answer if it worked for you.

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

カテゴリ

Help Center および File ExchangeWaveform Generation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by