1. PREPARED BY
NAME: DHARMESH TANK
MEMBERSHIP NO: 197445
STREAM: AMIETE-CS
SEMINAR CODE : AC-70
SUBMITTED TO,
INSTITUTE OF ELECTRONICS AND
TELECOMMUNICATION ENGINEER,
AHMEDABAD 8/7/2011
2. oUTLINE
HISTORY OF MATLAB
STRUCTURE OF MATLAB
MATLAB WINDOW
COMPARISION OF MATLAB
MATLAB PROGRAMMING
APPLICATIONS
ADVANTAGES & DISADVANTAGES
MATLAB IN TODAY
3. HISTORY OF MATLAB
Engineering and scientific application involve lots of
“Numbering Crunching”.
Such crunching generated some problems:-
Loss of precision and inaccurate results.
Underflow, overflow and didn’t recognize degeneracy.
Insufficient coding of algorithm.
Programming errors.
The U.S. Govt. recognized these insufficient problems and
they commissioned “Numerical Analysis” to write good
quality of algorithm for common tasks.
4. Continue.….
Make the results freely available as "libraries" of
subroutines than anyone can use in their programs.
Numerical analysis is based on numerical libraries:
1. LINPACK (Linear Algebra/LAPACK)
2. EISPACK (Eigen values & Eigen vectors)
CLEVE MOLOER, mathematician, C.S. Professor, and
co-author of LINPACK & EISPACK, thought this is still
too much work “write FORTRAN command, debug,
compile, run.....”.
He wanted to give students easy access to these
libraries.
5. INVENTION OF MATLAB
Then in 1970 Mr. MOLOER wrote MATLAB, which is
referred as “MATrix LABoratory”.
It’s provides interactive environment, easy input-
output, operation on whole vectors or matrix at once.
Matlab has the ability:-
Variable management
Data import and export
Calculation based on matrix
Generates plots and graphs
6. Continue….
These qualities made it’s popularity through mouth
publication.
JACK LITTLE, an engineer recognize its commercial
potential and joined with MOLOER & his friend
STEVE BANGERT rewrote the MATLAB in C language
with “M-FILES”(stored programs).
They established “MATHWORKS” company on DEC 7
1984 at Natick, Massachusetts, United States.
The “MATHWORKS” is now responsible for
development, sale, and support for MATLAB.
7. WHAT IS MATLAB ?
MATLAB is a fourth generation programming
language which provide numerical computing
environment, data visualization, data analysis and
interactive algorithm development feature.
MATLAB is a simple programming language with its
own extensive library of mathematical (M-files)and
graphical subroutines.
MATLAB is a software program that allows you to do
data manipulation and visualization, calculations,
math and programming. It can be used to do very
simple as well as very sophisticated tasks.
8. FEATURES OF MATLAB
High level language for technical computing.
Development environment for manage code, files ,
data visualization.
Mathematical function for linear algebra, statistics,
Fourier analysis.
Functions for integrating MATLAB based algorithms
with external applications and languages, such as C,
C++, Fortran,Java etc.
Use of toolboxes extend the MATLAB environment
to solve particular class of application problem.
9. STRUCTURE OF MATLAB
SERIES OF
MATLAB
COMMAND
(SCRIPT
FILE)
MATLAB
M FILE MAT FILE
COMMAND
LINE
FUNCATION
DATA
STORAGE/
LOADING
COMMAND
EXECUTION
LIKE DOS
WINDOW
INPUT
&
OUTPUT
CAPABILITY
10. Files that contain computer code known as M FILE.
It have two types : 1)script file 2)function file
1) Script file: It don’t take i/p arguments or return o/p
arguments.
2) Function file: whether this file take i/p arguments or
return o/p arguments.
*.m is the extension of M files.
MAT FILE (*.mat) is created by MATLAB with save
and read with load.
MEX FILE(*.mex) MATLAB callable codes compiled
from other language.
Continue….
11. Command Windows: Where all commands and
programs are run. Write the command or program
name and hit Enter.
Command History: Shows the last commands
run on the Command Windows. A command can
be recovered clicking twice.
Current directory: Shows the directory where
work will be done.
Workspace: To see the variables in use and their
dimensions (if working with matrices)
BASIC ELEMENTS OF MATLAB
13. FORTRAN C MATLAB
REQUIRED DATATYPE
(REAL,INTEGER,
CHARACTER)
REQUIRED DATATYPES
(double, int, char)
No data declaration
required
! Comments % Comments /* Comments */
DO WHILE (a.EQ.0)
…….
ENDDO
While (a==0
{……;
}
While a==0
………
End
READ *,a scanf a=input(‘a :’)
WRITE printf fprintf
f 77 code.f cc code.c Interpreted
14. MATLAB PROGRAMMING
There are no variable declaration necessary to perform
operation.
MATLAB use control flow:-
The for loop:-
syntax: for start : increment : end
command
end
The while loop:-
syntax: while expression
statements
end
15. If-else-end:-
syntax: if expression
commands(evaluate if exp. Is true)
else
commands(evaluate if exp. Is false)
end
Switch case:-
syntax: switch (expression)
case value 1(execute if exp. Evaluate case 1)
commands
case value 2(execute if exp. Evaluate case 2)
commands
.
.
otherwise
statements
end
16. regular & Logical expression
A logical array of 1 (true) and 0 (false) values is returned
as a result of applying logical operators to arrays;
Example :a = [4 0 -2 7 0]
1) a > 0 (Greater than)
ans =1 0 0 1 0
2) a == 7 (Equal to)
ans =0 0 0 1 0
3) a < 0 (Less than)
ans =0 0 1 0 0
17. 4) a ~= 0 (Not equal to)
ans =1 0 1 1 0
5) (a >= 0) && (a <= 4) (Logical AND)
ans =1 1 0 0 1
6)(a < 0) | (a > 4) (Logical OR)
ans =0 0 1 1 0
7)~((a < 0) | (a > 4)) (Logical NOT)
ans =1 1 0 0 1
18. Matrix manipulation
A =[1 2 3 4 ; 5 6 7 8]
A= 1 2 3 4
5 6 7 8
An empty array
A = [ ]
A = 1:5
A =1 2 3 4 5
A = 1:2:5
A =1 3 5
A = 10:-2:1
A=10 8 6 4 2
A = ones(1,5)
A =1 1 1 1 1
To create a identity
matrix:
eye(3)
ans =
1 0 0
0 1 0
0 0 1
19. Continue…
A(:) (Convert matrix to column vector)
ans = 1
5
3
7
A = A(:)' (Convert matrix to row vector)
ans = 1 5 3 7
A = 1 2 3 4 5
sum(A) (Array summation)
ans =15
20. Eg: A = 1 2 3 4 5
cumsum(A) (Cumulative summation)
ans = 1 3 6 10 15
Eg: A = 1 3 4
5 7 8
sum(A) (Simple summation)
ans = 6 10 12
sum(A,2) (Sum along rows)
ans = 8
20
sum(A,1) (Sum along columns)
ans = 6 10 12
sum(sum(A)) (Sum entire matrix)
ans =28
21. EXAMPLE: Plot the function sin(x) between
0≤x≤4π
Create an x-array of 100 samples between 0 and 4π.
Calculate sin(.) of the x-array
Plot the y-array
>>x=linspace(0,4*pi,100);
>>y=sin(x);
>>plot(y) 0 10 20 30 40 50 60 70 80 90 100
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
22. 1. help / lists all operators and special characters, along
with their descriptions.
2. help functionname displays a brief description and the
syntax for functionname in the Command Window.
3. help methodname displays help for the method
methodname. You may need to qualify methodname
with its class.
4. help classname displays help for the class classname.
You may need to qualify classname with its package.
etc..
Useful command
>>help command
23. Application of matlab
Control system design and Analysis.
Digital processing
Image & video processing and Computer vision
Computational Biology
Computational Finance
Mathematical Concepts(Magic square) and
Theory(Fibonacci series etc.)
Cryptography
Communication system
24. Advantage of matlab
MATLAB is provide its user accurate solution
of the problems & produce code easily.
MATLAB code is optimized to be quick when
performing matrix operation.
MATLAB is interpreted language, errors are
easier to fix.
Give visualize results without the need for
complicated and time consuming
programming.
Inexpensive software.
25. WEAKNESS OF MATLAB
MATLAB is not a general purpose programming
language.
MATLAB is interpreted language, make it some part
slower then compiled language such C++
MATLAB is designed for scientific computation so it’s
not suitable for some thing like(parsing text)
26. Matlab Today
Used to programs microprocessor and controller
A standard tool in both professional and academic use
"Toolboxes" providing functions for many applications:
control systems
identification
bio-informatics
statistics and time-series analysis
Can do symbolic mathematics, too.
Simulink: GUI based simulation tool