Matlab Introduction
Matlab Introduction
Matlab is a product of The Math Works, Inc. It is an outstanding software package for
scientific and engineering computations. Matlab enables us to solve many advanced
numerical problems fast and efficiently. It provides an interactive environment with
hundreds of built-in functions for technical computation, graphics, animation.
Matlab is both a computer programming language and a software environment for using
that language effectively. The name MATLAB stands for MATRIX LABORATORY.
Matlab is a high-level language whose basic data type is a matrix that does not require
dimensioning. It has a large collection of toolboxes in a variety of domains. Some
examples of Matlab toolboxes are control system, signal processing, image processing,
and system identification. The toolboxes consist of functions that can be used to perform
computations in a specific domain.
Matlab has many advantages compared to conventional computer languages for solvimg
technical problems. Matlab is an interactive system whose basic data type is a matrix that
does not require dimensioning. The software package has been commercially available
since 1984 and is now considered as a standard tool at most universities and industries
worldwide.
MATLAB WINDOWS
1. Command window:
This is the main window. It is characterized by Matlab command
prompt’>>’. All commands, including those for running user-written programs, are
typed in this window at the Matlab prompt.
2. Graphics Window:
The output of all graphics commands typed are flushed into the graphics or
figure window.
3. Edit Window:
This is a place to create, write, edit and save programs in files called M-
files. Any text editor can be used to carry out these tasks.
MATLAB COMMANDS
General-purpose commands
General information
helpbrowser - Bring up the help browser.
doc - Complete on-line help, displayed in the help browser.
help - M-file help, displayed at the command line.
helpwin - M-file help displayed in the help browser.
lookfor - Search all M-files for keyboard.
syntax - Help on Matlab command syntax.
Managing the workspace
workspace - Display Workspace browser, a GUI for managing the
workspace.
clear - Clear variables and functions from memory.
save - Save workspace variables to disk.
Matlab - Loads the program matlab into your workspace.
clear x - Deletes the matrix x from active workspace.
Complex
abs - absolute value
angle - phase angle
complex - construct complex data
conj - complex conjugate
real - complex real part
imag - complex imaginary part
Special matrices
zeros(n) - creates an n × n matrix whose elements are zero
zeros(m,n) - creates an m-row, n-column matrix of zeros
ones(n) - creates an n × n square matrix whose elements are 1’s
ones(m,n) - creates an m × n matrix whose elements are 1’s
eye(n) - creates an n × n identity matrix with 1’s on the diagonal
Miscellaneous commands
length(x) - returns the number of elements in a vector
size(x) - returns the size m(rows) and n(columns) of matrix x
rand - returns the random number between 0 and 1
rand(A) - returns a matrix of size A of random numbers