Plot +1 +1 -1 -1 rectangular pulse

조회 수: 14 (최근 30일)
nasz13
nasz13 2018년 1월 12일
댓글: nasz13 2018년 2월 9일
Hi,
I would like to ask for advice to help me to plot the rectangular pulse having +1 +1 -1 -1 in amplitude. Before, I plot with +1 -1 +1 -1, and this is fine because I use remainder, so it goes by odd and even. However, I don't know how to plot it with +1 +1 -1 -1 code. Can anyone please advice me on this? Below is my code;
for m = 0:Npulses
if rem(m,2) == 0 %i is even
Tx1 = exp(1j*pi*gamma*(t-m*PRI).^2);
W=ones(size(t));
W(t<m*PRI)=0;
W(t>(m*PRI+tau))=0;
s1 = Tx1.*W+s1;
else
Tx2 = -exp(1j*pi*gamma*(t-m*PRI).^2);%
W=ones(size(t));
W(t<m*PRI)=0;
W(t>(m*PRI+tau))=0;
s1 = Tx2.*W+s1;
end
end
where Npulses is number of pulses and PRI is Pulse Repetitive Interval.
  댓글 수: 1
nasz13
nasz13 2018년 2월 9일
Hi,
At this moment, I need to change the code to +1 -1 -1 +1 and also -1 +1 +1 -1. Can anyone please help me with this, based on my code above?

댓글을 달려면 로그인하십시오.

채택된 답변

Surya Pullakhandam
Surya Pullakhandam 2018년 1월 12일
편집: Surya Pullakhandam 2018년 1월 12일
Previously the pattern was repeating after every 2 occasions (+1 -1)(+1 -1). So, you used rem function with respect to 2. Now the pattern has to repeat after every 4 occasions (+1 +1 -1 -1)(+1 +1 -1 -1). So, let us use rem function with respect to 4. I think the changes as done below will suffice your requirement.
for m = 0:Npulses
if rem(m,4) == 0 | rem(m,4) == 1 %1st and 2nd term
Tx1 = exp(1j*pi*gamma*(t-m*PRI).^2);
W=ones(size(t));
W(t<m*PRI)=0;
W(t>(m*PRI+tau))=0;
s1 = Tx1.*W+s1;
else
Tx2 = -exp(1j*pi*gamma*(t-m*PRI).^2);
W=ones(size(t));
W(t<m*PRI)=0;
W(t>(m*PRI+tau))=0;
s1 = Tx2.*W+s1;
end
end
  댓글 수: 1
nasz13
nasz13 2018년 1월 13일
Thank you so much!! I really appreciate it, Surya.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by