Square wave with different amplitude for different time in number of cycles

조회 수: 5 (최근 30일)
How can i generate square wave with amplitude of 200 for the time interval [0,DT] and amplitude of -300 for the time interval of [DT,T] for n cycles, if D=0.5 and T=1/f=0.02. and number of cyles=3.
Thank you in advance!!!

채택된 답변

Walter Roberson
Walter Roberson 2019년 6월 16일
250 * square(parametric_times, D) - 50
parametric_times would be such that the end of the parametric_time vector was 2*pi*number_of_cycles (or better one sample before that)
parametric_times should map n*T to n*2*pi, and thus should be parametric_times = n*2*pi/T where n ranges from 0 to 3.
  댓글 수: 1
Selam Dagne
Selam Dagne 2019년 6월 18일
Thank you walter for your answer!
This works for number of cycles but how can we differenciate the time interval for specific amplitude. The code below plot the square wave which have amplitude of 200 for starting(0) and ending point(1) and -300 for other operating point.But i want to plot the square wave which have amplitude of 200 for the interval from time t=0 to t=D*T and -300 for the time interval from time t=D*T to t=T.How can i get this type of square wave?
dt=1e-9;
Ncy=1;
f=100e3;
t=0:dt:Ncy/f;
T=1/f;
w=2*pi*f;
D=0.5;
parametric_times=w*t;
VL=250 * square(parametric_times, D) - 50;
plot(t,VL)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by