8/12/2019 MATLAB Introduction Programming For DSP
1/16
MATLAB
Introduction
8/12/2019 MATLAB Introduction Programming For DSP
2/16
MATLAB is a software package for highperformance numerical computation andvisualization.
It provides an interactive environment withmany built-in functions for technicalcomputations
MATLABMATrix LABoratory
Introduction
8/12/2019 MATLAB Introduction Programming For DSP
3/16
Introduction
MATLAB is matrix-oriented, so what wouldtake several statements in C or Fortran can
usually be accomplished in just a few lines using
MATLAB's built-in matrix and vectoroperations.
MATLAB Graphical User Interface (GUI)
tools enable to use MATLAB as anapplication development tool.
8/12/2019 MATLAB Introduction Programming For DSP
4/16
Introduction
MATLABs built-in functions provideexcellent tools for:
Linear Algebra
Data Analysis
Signal Processing
Image Processing
Speech Processing
Control System Design
8/12/2019 MATLAB Introduction Programming For DSP
5/16
All data in MATLAB are stored as arrays. Allows to quickly manipulate sets of data in a wide
variety of ways.
Addition to matrix orientation, offers programmingfeatures that are similar to those of other
programming languages.
Introduction
8/12/2019 MATLAB Introduction Programming For DSP
6/16
Introduction
MATLAB desktop: This window is the primarygraphical user interface for MATLAB.
Command window: The primary place wherein
we can interact with MATLAB. The cursor and prompt (>>) signify that
MATLAB is waiting to perform a mathematical
operation.
8/12/2019 MATLAB Introduction Programming For DSP
7/16
Introduction
Z = 10 Creates a variable named z, stores a value 10 in
it, saves it as a part of memory known as
workspace browser. All commands executed in the command widow
share a common workspace, so that they can all
share a variable.
8/12/2019 MATLAB Introduction Programming For DSP
8/16
Introduction
Save: Stores workspace values (variable names, sizes, and values), inthe binary file matlab.mat in the present working directory
save data:
Stores all workspace values in the file data.mat
save data_1 x y:
Stores only the variables x and y in the file data_1.mat
load data 1:
Loads the values of the workspace values previously stored in thefile data_1.mat
8/12/2019 MATLAB Introduction Programming For DSP
9/16
Introduction
The collection of variables in a MATLAB session iscalled the workspace.
To list the variables in the workspace, type who.
To list the variables with their sizes, type whos.
To delete a variable from the workspace, type clear
variable.
Typing clear by itself clears all the variables from the
workspace.
8/12/2019 MATLAB Introduction Programming For DSP
10/16
Introduction
Workspace operations Command line who - list all variables
whos - variable names, types and sizes clear var1 var2- delete listed variables
clear - delete all variables
Desktop tools Edit menu (clear workspace)
Workspace viewer + context menu
8/12/2019 MATLAB Introduction Programming For DSP
11/16
Introduction
Has a number of predefined special values They can be used at any time in MATLAB
These predefined values are stored as ordinary
variables in the workspace so they can beoverwritten or modified by the user.
But it is customary to never redefine a
predefined variable
8/12/2019 MATLAB Introduction Programming For DSP
12/16
Introduction
Some of the predefined special values are: pi, i, j, Inf, NaN, clock, date, eps, ans
NaN = not a number (0/0)
eps = is the smallest difference between two
numbers that can be represented by the
computer.
ans = name of an undefined variable.
8/12/2019 MATLAB Introduction Programming For DSP
13/16
Special values
ans: answer when expression is not assigned
eps: Floating point precision
pi: 3.141592653589793
i,j: Square root of (-1)
inf: NaN: Not a Number
clock: Time and Date
tic, toc: Stopwatch timer functions
flops: Floating point operation count nargin: number of function input arguments
nargout: number of function output arguments
Introduction
8/12/2019 MATLAB Introduction Programming For DSP
14/16
Introduction General Purpose Commands
help: Help facility demo: Run demonstrations
who: list variables in memory
what: list m-files on disk
size: row and column dimensions
length: Vector length
clear: Clear workspace computer: Type of Computer
ctrl+C: local abort
quit: terminate program
exit: same as quit
clc: clear command screen
home: home cursor
format: set output display format disp: display matrix or text
fprintf: print formatted number in a file
Echo: Enable command echoing
More: Control paged output in command window
8/12/2019 MATLAB Introduction Programming For DSP
15/16
Introduction
Debugging Commands
dbstop: set breakpoint
dbclear: remove breakpoint
dbcont: resume execution
dbdown: change local workspace context dbstack: list who called whom
dbstatus: list all breakpoints
dbstep: execute one or more lines
dbtype: list M-le with line numbers dbup: change local workspace context
dbquit: quit debug mode
8/12/2019 MATLAB Introduction Programming For DSP
16/16
Introduction
File Manipulation dir: Directory of files on disk
type: list file
delete: Delete file
cd: Change Directory
Top Related