06.06.2022 Views

B. P. Lathi, Zhi Ding - Modern Digital and Analog Communication Systems-Oxford University Press (2009)

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.8 MATLAB Exercises 47

Basic Signals and Signal Graphing

Basic functions can be defined by using MATLAB's m-files. We gave three MATLAB programs

that implement three basic functions when a time vector t is provided:

us tep . m implements the unit step function u(t)

rect . m implements the standard rectangular function rect(t)

triangl . m implements standard triangle function (t)

% (file name : ustep .m)

% The unit step function is a function of time 't' .

% Usage y ustep(t)

%

% ustep (t)

% ustep (t)

%

0

1,

if t < 0

if t >= 1

% t - must be real-valued and can be a vector or a matrix

%

function y=ustep (t)

y = (t>=O) ;

end

% (file name : rect .m)

% The rectangular function is a function of time 't' .

%

% Usage y = rect (t)

% t - must be real-valued and can be a vector or a matrix

%

% rect (t)

% rect (t)

%

1,

0,

if l tl < o.5

if l t l > o.5

function y=rect (t)

y =(sign (t+0 .5)-sign(t- 0.5) >0) ;

end

% (file name : triangl .m)

% The triangle function is a function of time 't' .

%

% triangl (t)

% triangl (t)

%

% Usage y

1- l t l , if l t l < 1

O, if l t l > l

triangl (t)

% t - must be real-valued and can be a vector or a matrix

%

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!