Digital Signal Processing Reference
In-Depth Information
• Open a file in any text editor (either in MATLAB or otherwise) and
write the program.
• After writing the program, exit the program after saving it as a
filename.m file.
• To execute the program, either run the file from the MATLAB text
editor or type the filename after the prompt:
>> filename
The program will run, and the results and error messages, if any, will be
displayed on the screen. Plots will appear on a new screen.
Numbers
Example: Generate the real numbers z 1 = 3, z 2 = 4.
>> z1 = 3
>> z2 = 4
Example: Generate the complex numbers z 1 = 3+ j 4, z 2 = 4+ j 5.
>> z1 = 3+j*4
>> z2 = 4+j*5
N OTE : The symbol i can be used instead of j to represent
.
1
Example: Find the magnitude and phase of the complex number z = 3 + j 4.
>> z = 3+j*4
>> zm = abs(z); gives the magnitude of z
>> zp = angle(z); gives the phase of z in radians
Addition or subtraction of numbers (real or complex):
>> z = z1+z2; addition
>> z = z1-z2; subtraction
Multiplication or division of numbers (real or complex):
>> z = z1*z2; multiplication
>> z = z1/z2; division
Vectors and Matrices
Example: Generate the vectors x = [1 3 5] and y = [2 0 4 5 6].
>> x = [1 3 5]; generates the vector of length 3
>> y = [2 0 4 5 6]; generates the vector of length 5
Addition or subtraction of vectors x and y of same length:
>> z = x+y; addition
>> z = x-y; subtraction
Search WWH ::




Custom Search