This document provides an overview of basic MATLAB concepts including:
1. Creating variables and performing basic arithmetic operations
2. Generating and manipulating matrices using built-in functions
3. Plotting graphs of simple functions like sine and cosine waves
4. Solving linear equations and finding the inverse and determinant of matrices
It includes sample exercises demonstrating these MATLAB skills.
1. SIGNALS AND SYSTEMS
BY
LIM, JONATHAN G.
Getting Started with MATLAB
Arrays and Matrices
Digital Image Processing
Audio Signal Processing
2. BASIC MATLAB OPERATOR
Basic Arithmetic Operators
Operation Symbol
Addition +
Subtraction -
Multiplication *
Division /
Power ^
3. MATLAB variables are created with an assignment statement. The syntax of
variable assignment is
variable name = a value (or an expression)
For example,
>> addition = 25 + 75;
>> y = (900 / 300) + 2*5
CREATING MATLAB VARIABLES
6. BASIC PLOTTING
The MATLAB command to plot a graph is plot(x,y). The vectors x
= (1; 2; 3; 4; 5; 6) and y = (3; -1; 2; 4; 5; 1)
>> x = [1 2 3 4 5 6];
>> y = [3 -1 2 4 5 1];
>> plot(x,y)
7.
8. PLOTTING SINE WAVE SIGNAL
>> x = 0: pi/100 : 2*pi; % 0-2π with increment of
π
100
>> y = sin(x); % starts at 0,
>> plot(x,y) % takes steps (or increments) of
π
100
,
% stops when 2¼ is reached.
15. MATRIX GENERATION
• Matrices are fundamental to MATLAB. Therefore, we need to
become familiar with matrix generation and manipulation.
Matrices can be generated in several ways.
• A vector is a special case of a matrix.
16. An array of dimension (1x n) is called a row vector, whereas an
array of dimension (m x1) is called a column vector.
>> row = [1 4 7 10 13] % row vector
>> column = [1;4;7;10;13] % column vector
Converting Row Vector to Column Vector or Vice Versa using Transpose. The
transpose operation is denoted by an apostrophe or a single quote (').
>> row = row’
>>column = column’
17. ENTERING A MATRIX
A matrix is an array of numbers. To type a matrix into MATLAB you
must
1. Begin with a square bracket, [
2. Separate elements in a row with spaces or commas (,)
3. Use a semicolon (;) to separate rows
4. End the matrix with another square bracket, ].
>> A = [1 2 3; 4 5 6; 7 8 9]A =
1 2 3
4 5 6
7 8 9
23. EXERCISES
1. Solve for the value of x, the inverse and determinants. Store in
variable X, INV and DET respectively
24. EXERCISES
2. Liz buys three apples, a dozen bananas, and one cantaloupe
for $2.36. Bob buys a dozen apples and two cantaloupe for
$5.26. Carol buys two bananas and three cantaloupe for $2.77.
How much do single pieces of each fruit cost?