📄 urect.m
字号:
function y=urect(t,a)
% URECT Unit Rectangle Function.
%
% Y=URECT(t) generates a rectangle of height=1, width=1,centered at t=0.
% The end-values of urect(t) at t=0.5 and t=0.5 equal 1.
%
% Y=URECT(T,A) generates a rectangle with end-values = A.
%
% URECT (with no input arguments) invokes the following example:
%
% % Plot 2*urect((t-1)/3,0.5), a CT rect with height=2, width=3,
% % centered at t=1, and end-values = 0.5
% >>t=-4:.05:4;
% >>yt=2*urect((t-1)/3,0.5);
% >>plot(t,yt),grid
%
% See Also: UDELTA, URAMP, USTEP, TRI
% ADSP Toolbox: Version 2.0
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998
if nargin==0,
help urect
disp('Strike a key to see results of the example')
pause
t0=-4:.05:4;
yt=2*urect((t0-1)/3,0.5);
v=matverch;
if v < 4, eval('clg');else,eval('clf');end
axis([-4 4 0 3])
plot(t0,yt)
axis([-4 4 0 3])
grid
hold off
return
end
z=abs(t);
if nargin == 1,
y=(z<=0.5);
elseif nargin == 2,
y=(z<0.5)+a*(z==0.5);
elseif nargin > 2,
error('Too many input arguments');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -