About rectangular pulse wave function code.
조회 수: 2 (최근 30일)
이전 댓글 표시
function y = rect_pulse(t_vec,tau)
% This function generates a rectangular pulse of pulse width tau.
% Generated pulse is centered about t=0.
% By default, the generated pulse has width 1.
% The signal has value 1 in interval [-Tw/2,+Tw/2)
%
if nargin<2, tau=1; end
y = double(abs(t_vec)<tau/2-eps);
y(abs(t_vec-(-tau/2))<eps) = 1.0;
This code is generating the rectangular pulse wave.
but i can't understand the last two lines.
First, where the 0? fundamentally rectangular pulse has 0 except for the width range.
how can the zero make in this code?
Next, is there conditional code beside 'if' or 'elseif'?
because in 'y=double(~~)' '~~' looks like conditional code.
Thank you for your help.
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!