Info

此问题已关闭。 请重新打开它进行编辑或回答。

About rectangular pulse wave function code.

1 次查看(过去 30 天)
Junu Lee
Junu Lee 2020-5-8
关闭: Sabin 2024-12-13
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 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by