Matlab Introduction

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

INTRODUCTION TO MATLAB

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.

Elementary math functions


Trignometric
sin - sine
sinh - hyperbolic sine
asin - inverse sin
asinh - inverse hyperbolic sine
cos - cosine
cosh - hyperbolic cosine
aos - inverse cosine
aosh - inverse hyperbolic cosine
tan - tangent
tanh - hyperbolic tangent
sec - secant
sech - hyperbolic secant
csc - cosecant
cot - cotangent
coth - hyperbolic cotangent
Exponential
exp - exponential
log - natural logarithm
sqrt - square root

Complex
abs - absolute value
angle - phase angle
complex - construct complex data
conj - complex conjugate
real - complex real part
imag - complex imaginary part

Rounding and remainder


fix - round toward zero
round - round towards nearest integer
mod - modulus
rem - remainder
sign - signum

Commands useful in plotting


semilogx(x,y) - plots log(x) vs. y
loglog(x,y) - plots log(x) vs log(y)
title(‘text’) - places a title at the top of graphics plot
xlabel(‘text’) - writes text beneath the x-axis of a plot
axis - controls axis scaling and appearance
subplot - creates axes in tiled positions
Data analysis commands
max(x) - returns the maximum value of the elements in a vector
or if x is a matrix, returns a row vector whose elements
are the maximum values from each respective column
of the matrix
min(x) - returns the minimum value of x
mean(x) - returns the mean value of x
sum(x) - returns the sum of the elements of a vector or if x is a
matrix, returns the sum of the elements from each
respective column of the matrix.
sort(x) - sort the values in the vector x or the columns of a
matrix and places them in ascending order.
hist(x) - plots a histogram of the elements of the vector x

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

You might also like