Digital Signal Processing Reference
In-Depth Information
% sub ¼ x1-x2
sum ¼ x1+x2; % Add two numbers
sub ¼ x1-x2; % Subtract x2 from x1
To use the MATLAB function, go to the folder that contains sumsub.m. At the MATLAB prompt,
try the following:
»
help sumsub % Display usage information on MATLAB prompt
sumsub: Function to add and subtract two numbers
usage:
[sum, sub]
sumsub(x1,x2)
¼
x1
the first number
¼
x2
the second number
¼
sum
x1+x2;
sub ¼ x1-x2
Run the function as follows:
¼
»
[x1, x2] ¼ sumsub(3, 4-3i);
% Call function sumsub
»
x1
% Display the result of sum
x1 ¼
7.0000 - 3.0000i
»
x2
% Display the result of subtraction
x2 ¼
-1.0000 + 3.0000i
MATLAB functions can also be used inside an m-file. More MATLAB exercises for introduction to
DSP can be explored in McClellan, Schafer, and Yoder (1998) and Stearns (2003).
Search WWH ::




Custom Search