SlideShare a Scribd company logo
1 of 30
MATLAB AND ITS
APPLICATIONS
1
Submitted by:
Ayush Pandey
Submitted to:
Mr. Ashirwad Dubey
CERTIFICATE
MATLAB
• MATLAB is a program for doing numerical
computation. It was originally designed for solving
linear algebra type problems using matrices. It’s name
is derived from
Matrix Laboratory.
• MATLAB has since been expanded and now has built-
in functions for solving problems requiring data
analysis, signal processing, optimization, and several
other types of scientific computations. It also contains
functions for 2-D and 3-D graphics and animation.
MATLAB
• When you first open MATLAB, notice:
1.The command window is where you'll give
MATLAB its input and view its output.
2.The workspace shows you all of your
current working variables and other
objects.
3.The history shows you all commands you
used in CW.
4.The Editor for MATLAB scripts (M-files) .
To save & run the m-file type 'F5'. To open
the editor with a new or old m-file use the
command open file name
MATLAB'S POWER OF
COMPUTATIONAL MATHEMATICS
• Dealing with Matrices and Arrays
• 2-D and 3-D Plotting and graphics
• Linear Algebra
• Algebraic Equations
• Non-linear Functions
• Statistics
• Data Analysis
• Calculus and Differential Equations
• Numerical Calculations
• Integration
• Transforms
• Curve Fitting
• Various other special functions
MATLAB HELP
• For help, command description etc use F1 or following
commands:
• help command_name
• helpwin command_name
• doc command_name
• helpdesk command_name
• demo command_name
• lookfor keyword (search unknown command)
• http://www.mathworks.com/support/
• For example when running “help sin” one get
SIN Sine of argument in radians.
SIN(X) is the sine of the elements of X.
See also ASIN, SIND.
Overloaded functions
Reference page in Help browser doc sin
SOME USEFUL COMMANDS
• what List all m-files in current directory
• dir/ls List all files in current directory
• type test Display test.m in command window
• delete test Delete test.m
• cd/chdir Change directory
• pwd Show current directory
• which test Display directory path to ‘closest’
test.m
• who List known variables
• whos List known variables plus their size
• clear Clear variables from workspace
• clc Clear the command window
MATLAB & MATRICES
MATLAB treats all variables as matrices. For our
purposes a matrix can be thought of as an array,
in fact, that is how it is stored.
Vectors are special forms of matrices and contain
only one row OR one column.
Scalars are matrices with only one row AND one
column
VARIABLE NAMES
Variable names ARE case sensitive
Variable names can contain up to 63 characters (as of
MATLAB 6.5 and newer). One can use namelengthmax
command to verify it.
Variable names must start with a letter followed by letters,
digits, and underscores.
MATLAB variables are defined by assignment. There is no
need to declare in advance the variables that we want to use
or their type.
Example
x=1; % Define the scalar variable x
y=[1 2 3] % row vector
z=[1;2;3] % column vector
A=[1 2 3;4 5 6;7 8 9] % 3x3 matrix
whos % List of the variables defined
Note: terminate statement with semicolon (;) to suppress
SPECIAL VARIABLES
ans Default variable name for results
pi Value of π
eps Smallest incremental number
inf Infinity
NaN Not a number e.g. 0/0
i,j,1i,1j imaginary unit i, i.e. square root of -
1
realmin The smallest usable positive
realnumber
realmax The largest usable positive real
number
SpecialVars.m
OTHER SYMBOLS
>> prompt
. . . continue statement on next line
, separate statements and data
% start comment which ends at end of line
; (1) suppress output
(2) used as a row separator in a matrix
: specify range
RELATIONAL OPERATORS
• MATLAB supports six relational operators.
Less Than <
Less Than or Equal <=
Greater Than >
Greater Than or Equal >=
Equal To ==
Not Equal To ~=
MATH & ASSIGNMENT
OPERATORS
Power ^ or .^ a^b or a.^b
Multiplication * or .* a*b or a.*b
Division / or ./ a/b or a./b
or  or . ba or b.a
NOTE: 56/8 = 856
- (unary) + (unary)
Addition + a + b
Subtraction - a - b
Assignment = a = b (assign b to a)
Operators.m
MATLAB LOGICAL OPERATORS
• MATLAB supports five logical operators.
not/~ element wise/scalar logical NOT
and/& element wise logical AND
or / | element wise logical OR
&& logical (short-circuit) AND
|| logical (short-circuit) AND
LOGICAL FUNCTIONS
MATLAB also supports some logical
functions.
xor (a, b) exclusive or
any(x) returns 1 if any element of x is
nonzero
all(x) returns 1 if all elements of x are
nonzero
isnan(x) returns 1 at each NaN in x
isinf(x) returns 1 at each infinity in x
finite(x) returns 1 at each finite value in x
SOME MATRIX FUNCTIONS
• zeros(rows, cols) – create zero matrix
• rand(rows, cols) – generate random
matrix
• ones(rows, cols) – matrix with 1 in all
entries
• eye (rows, cols) – identity matrix
• sub2ind, ind2sub indices manipulation
EXTRACTING A SUB-MATRIX
A portion of a matrix can be extracted and stored in a
smaller matrix by specifying the names of both matrices
and the rows and columns to extract. The syntax is:
sub_matrix = matrix ( r1 : rn , c1 : cn ) ;
sub_matrix = matrix ( r1 : rn , : ) ;
sub_matrix = matrix ( : , c1 : cn ) ;
sub_matrix = matrix ( r1 : dr : rn , c1 : dc : cn ) ;
where r1 and rn specify the beginning and ending rows
and c1 and cn specify the beginning and ending
columns to be extracted to make the new matrix.
The terms dr and dc define spacing different than one.
matrix.m
“CONTINUOUS” FUNCTIONS
• Numerically, we cannot represent a general continuous
function (x,f(x)) because it requires handling infinite data (for
each point in the range, we need to keep f(x)). Instead, we
represent a function by its values at a finite number of data
points (x_i,f(x_i)), where the series of points {x_i} is typically
referred to as the sampling points or the grid points.
Accordingly, the "continuous" functions in Matlab accepts a
vector of point {x_i} and return a vector of values {f(x_i)}.
• Some functions
• sqrt
• log
• cos/acos/sin/asin etc
• exp - exponential
• abs
• sign
• norm
• sum
• prod - product
PLOTTING
• MATLAB will plot one vector vs. another. The first one will be
treated as the abscissa (or x) vector and the second as the
ordinate (or y) vector. The vectors have to be the same length.
• MATLAB will also plot a vector vs. its own index. The index will
be treated as the abscissa vector. Given a vector “time” and a
vector “dist” we could say:
>> plot (time, dist) % plotting versus time
>> plot (time + i*dist) % plotting versus time
>> plot (dist) % plotting versus index
• Sometime we want to see it with different colorline stile
>> plot (time, dist, line_characteristics)
• And sometime we want to plot few functions in graphs
>> plot(…), hold, plot(…)
>> plot(t,d1,l_c1, t,d2, l_c2)
• To split page to several axes check use
>> subplot (rows, cols, place)
a = 3;
b = a*a;
c = a*a*a;
d = sqrt(a);
fprintf('%4u square equals %4u r', a, b)
fprintf('%4u cube equals %4u r', a, c)
fprintf('The square root of %2u is %6.4f r', a, d)
Output:
3 square equals 9
3 cube equals 27
The square root of 3 is 1.7321
PLOTTING
There are commands in MATLAB to "annotate" a plot to put on
axis labels, titles, and legends. For example:
To put a label on the axes we would use:
>> xlabel ('X-axis label')
>> ylabel ('Y-axis label')
To put a title on the plot, we would use:
>> title ('Title of my plot')
To distinct between function in the graph use:
>> legend(legend_1, legend_2)
plotting.m
FLOW CONTROL (CONDITION)
• An if - elseif - else structure. (Note that elseif is one word)
if expression1
statements1
elseif expression2
statements2
else
statements3
end
• An switch-case structure
switch switch_expr
case case_expr
statement, ..., statement
case {case_expr1, case_expr2, case_expr3, ...}
statement, ..., statement
otherwise
statement, ..., statement
end
FLOW CONTROL (LOOPS)
• A for loop in MATLAB
for ind = 1:100
b(ind)=sin(ind/10)
end
• Alternative (Most of the loops can be avoided!!!):
x=0.1:0.1:10;
b=sin(x);
• A while loop in
while x <= 10
% execute these commands
end
M-FILES
• An M-file might be used as a script, i.e. file consist
set of statements
• In additional, one use M-files to write function, in
this case the file starts with function definition like:
function y = f(x)
function [u,v] = f(x,y,z)
• File name and the name of function in the file are
usually identical, however while they are different,
MATLAB use file name to call function.
• If you add additional function in same M-file, it
considered sub-function and might be called from
inside the M-file only. Only the first function might
be called from outside.
SAVING RESULTS
• We can save all our results for future reference .
• The command
diary ‘FileName'
saves all output to command window into the FileName.txt file
until this option is turned off by the command
diary off
• The following commands save & load the entire
workspace into the file 'MyMatFile.mat'
• save 'MyMatFile'
• load 'MyMatFile'
• save 'x.mat' x % save a specific variable
• saving in ASCII format:
• x = (-1:0.4:1)' ; y = sin(x*pi)
• var = [x y] % double-column
• save 'my_sin.dat' -ASCII -double var %Save in 16-digit ASCII
format
SIMULINK
• Simulink is a simulation and model-based design
environment for dynamic and embedded systems,
integrated with MATLAB. Simulink, also developed by
MathWorks, is a data flow graphical programming
language tool for modelling, simulating and analyzing
multi-domain dynamic systems. It is basically a graphical
block diagramming tool with customizable set of block
libraries.
SIMULINK SUPPORTS
• system-level design
• simulation
• automatic code generation
• testing and verification of embedded systems
APPLICATIONS OF MATLAB
• Statistics and machine learning(ML) This toolbox in MATLAB can be very handy for the
programmers. ...
• Curve fitting. The curve fitting toolbox helps to analyze the pattern of occurrence of data. ...
• Control systems. ...
• Signal Processing. ...
• Mapping. ...
• Deep learning. ...
• Financial analysis. ...
• Image processing.
USES
• Signal Processing and Communications
• Image and Video Processing
• Control Systems
• Test and Measurement
• Computational Finance
• Computational Biology
Thank You

More Related Content

Similar to MatlabIntro (1).ppt

Similar to MatlabIntro (1).ppt (20)

From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyond
 
MATLAB INTRODUCTION
MATLAB INTRODUCTIONMATLAB INTRODUCTION
MATLAB INTRODUCTION
 
Matlab Manual
Matlab ManualMatlab Manual
Matlab Manual
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab session
 
Matlab
MatlabMatlab
Matlab
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
 
Matlab anilkumar
Matlab  anilkumarMatlab  anilkumar
Matlab anilkumar
 
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxMATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
 
Matlab
MatlabMatlab
Matlab
 
Matlab lec1
Matlab lec1Matlab lec1
Matlab lec1
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
EE6711 Power System Simulation Lab manual
EE6711 Power System Simulation Lab manualEE6711 Power System Simulation Lab manual
EE6711 Power System Simulation Lab manual
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - IMatlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - I
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
 
Matlab Tutorial.ppt
Matlab Tutorial.pptMatlab Tutorial.ppt
Matlab Tutorial.ppt
 
Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in space
 
Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4
 

Recently uploaded

VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kestopur 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Roomdivyansh0kumar0
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一3sw2qly1
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Complet Documnetation for Smart Assistant Application for Disabled Person
Complet Documnetation   for Smart Assistant Application for Disabled PersonComplet Documnetation   for Smart Assistant Application for Disabled Person
Complet Documnetation for Smart Assistant Application for Disabled Personfurqan222004
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 

Recently uploaded (20)

VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kestopur 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Complet Documnetation for Smart Assistant Application for Disabled Person
Complet Documnetation   for Smart Assistant Application for Disabled PersonComplet Documnetation   for Smart Assistant Application for Disabled Person
Complet Documnetation for Smart Assistant Application for Disabled Person
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 

MatlabIntro (1).ppt

  • 1. MATLAB AND ITS APPLICATIONS 1 Submitted by: Ayush Pandey Submitted to: Mr. Ashirwad Dubey
  • 3. MATLAB • MATLAB is a program for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It’s name is derived from Matrix Laboratory. • MATLAB has since been expanded and now has built- in functions for solving problems requiring data analysis, signal processing, optimization, and several other types of scientific computations. It also contains functions for 2-D and 3-D graphics and animation.
  • 4. MATLAB • When you first open MATLAB, notice: 1.The command window is where you'll give MATLAB its input and view its output. 2.The workspace shows you all of your current working variables and other objects. 3.The history shows you all commands you used in CW. 4.The Editor for MATLAB scripts (M-files) . To save & run the m-file type 'F5'. To open the editor with a new or old m-file use the command open file name
  • 5. MATLAB'S POWER OF COMPUTATIONAL MATHEMATICS • Dealing with Matrices and Arrays • 2-D and 3-D Plotting and graphics • Linear Algebra • Algebraic Equations • Non-linear Functions • Statistics • Data Analysis • Calculus and Differential Equations • Numerical Calculations • Integration • Transforms • Curve Fitting • Various other special functions
  • 6. MATLAB HELP • For help, command description etc use F1 or following commands: • help command_name • helpwin command_name • doc command_name • helpdesk command_name • demo command_name • lookfor keyword (search unknown command) • http://www.mathworks.com/support/ • For example when running “help sin” one get SIN Sine of argument in radians. SIN(X) is the sine of the elements of X. See also ASIN, SIND. Overloaded functions Reference page in Help browser doc sin
  • 7. SOME USEFUL COMMANDS • what List all m-files in current directory • dir/ls List all files in current directory • type test Display test.m in command window • delete test Delete test.m • cd/chdir Change directory • pwd Show current directory • which test Display directory path to ‘closest’ test.m • who List known variables • whos List known variables plus their size • clear Clear variables from workspace • clc Clear the command window
  • 8. MATLAB & MATRICES MATLAB treats all variables as matrices. For our purposes a matrix can be thought of as an array, in fact, that is how it is stored. Vectors are special forms of matrices and contain only one row OR one column. Scalars are matrices with only one row AND one column
  • 9. VARIABLE NAMES Variable names ARE case sensitive Variable names can contain up to 63 characters (as of MATLAB 6.5 and newer). One can use namelengthmax command to verify it. Variable names must start with a letter followed by letters, digits, and underscores. MATLAB variables are defined by assignment. There is no need to declare in advance the variables that we want to use or their type. Example x=1; % Define the scalar variable x y=[1 2 3] % row vector z=[1;2;3] % column vector A=[1 2 3;4 5 6;7 8 9] % 3x3 matrix whos % List of the variables defined Note: terminate statement with semicolon (;) to suppress
  • 10. SPECIAL VARIABLES ans Default variable name for results pi Value of π eps Smallest incremental number inf Infinity NaN Not a number e.g. 0/0 i,j,1i,1j imaginary unit i, i.e. square root of - 1 realmin The smallest usable positive realnumber realmax The largest usable positive real number SpecialVars.m
  • 11. OTHER SYMBOLS >> prompt . . . continue statement on next line , separate statements and data % start comment which ends at end of line ; (1) suppress output (2) used as a row separator in a matrix : specify range
  • 12. RELATIONAL OPERATORS • MATLAB supports six relational operators. Less Than < Less Than or Equal <= Greater Than > Greater Than or Equal >= Equal To == Not Equal To ~=
  • 13. MATH & ASSIGNMENT OPERATORS Power ^ or .^ a^b or a.^b Multiplication * or .* a*b or a.*b Division / or ./ a/b or a./b or or . ba or b.a NOTE: 56/8 = 856 - (unary) + (unary) Addition + a + b Subtraction - a - b Assignment = a = b (assign b to a) Operators.m
  • 14. MATLAB LOGICAL OPERATORS • MATLAB supports five logical operators. not/~ element wise/scalar logical NOT and/& element wise logical AND or / | element wise logical OR && logical (short-circuit) AND || logical (short-circuit) AND
  • 15. LOGICAL FUNCTIONS MATLAB also supports some logical functions. xor (a, b) exclusive or any(x) returns 1 if any element of x is nonzero all(x) returns 1 if all elements of x are nonzero isnan(x) returns 1 at each NaN in x isinf(x) returns 1 at each infinity in x finite(x) returns 1 at each finite value in x
  • 16. SOME MATRIX FUNCTIONS • zeros(rows, cols) – create zero matrix • rand(rows, cols) – generate random matrix • ones(rows, cols) – matrix with 1 in all entries • eye (rows, cols) – identity matrix • sub2ind, ind2sub indices manipulation
  • 17. EXTRACTING A SUB-MATRIX A portion of a matrix can be extracted and stored in a smaller matrix by specifying the names of both matrices and the rows and columns to extract. The syntax is: sub_matrix = matrix ( r1 : rn , c1 : cn ) ; sub_matrix = matrix ( r1 : rn , : ) ; sub_matrix = matrix ( : , c1 : cn ) ; sub_matrix = matrix ( r1 : dr : rn , c1 : dc : cn ) ; where r1 and rn specify the beginning and ending rows and c1 and cn specify the beginning and ending columns to be extracted to make the new matrix. The terms dr and dc define spacing different than one. matrix.m
  • 18. “CONTINUOUS” FUNCTIONS • Numerically, we cannot represent a general continuous function (x,f(x)) because it requires handling infinite data (for each point in the range, we need to keep f(x)). Instead, we represent a function by its values at a finite number of data points (x_i,f(x_i)), where the series of points {x_i} is typically referred to as the sampling points or the grid points. Accordingly, the "continuous" functions in Matlab accepts a vector of point {x_i} and return a vector of values {f(x_i)}. • Some functions • sqrt • log • cos/acos/sin/asin etc • exp - exponential • abs • sign • norm • sum • prod - product
  • 19. PLOTTING • MATLAB will plot one vector vs. another. The first one will be treated as the abscissa (or x) vector and the second as the ordinate (or y) vector. The vectors have to be the same length. • MATLAB will also plot a vector vs. its own index. The index will be treated as the abscissa vector. Given a vector “time” and a vector “dist” we could say: >> plot (time, dist) % plotting versus time >> plot (time + i*dist) % plotting versus time >> plot (dist) % plotting versus index • Sometime we want to see it with different colorline stile >> plot (time, dist, line_characteristics) • And sometime we want to plot few functions in graphs >> plot(…), hold, plot(…) >> plot(t,d1,l_c1, t,d2, l_c2) • To split page to several axes check use >> subplot (rows, cols, place)
  • 20. a = 3; b = a*a; c = a*a*a; d = sqrt(a); fprintf('%4u square equals %4u r', a, b) fprintf('%4u cube equals %4u r', a, c) fprintf('The square root of %2u is %6.4f r', a, d) Output: 3 square equals 9 3 cube equals 27 The square root of 3 is 1.7321
  • 21. PLOTTING There are commands in MATLAB to "annotate" a plot to put on axis labels, titles, and legends. For example: To put a label on the axes we would use: >> xlabel ('X-axis label') >> ylabel ('Y-axis label') To put a title on the plot, we would use: >> title ('Title of my plot') To distinct between function in the graph use: >> legend(legend_1, legend_2) plotting.m
  • 22. FLOW CONTROL (CONDITION) • An if - elseif - else structure. (Note that elseif is one word) if expression1 statements1 elseif expression2 statements2 else statements3 end • An switch-case structure switch switch_expr case case_expr statement, ..., statement case {case_expr1, case_expr2, case_expr3, ...} statement, ..., statement otherwise statement, ..., statement end
  • 23. FLOW CONTROL (LOOPS) • A for loop in MATLAB for ind = 1:100 b(ind)=sin(ind/10) end • Alternative (Most of the loops can be avoided!!!): x=0.1:0.1:10; b=sin(x); • A while loop in while x <= 10 % execute these commands end
  • 24. M-FILES • An M-file might be used as a script, i.e. file consist set of statements • In additional, one use M-files to write function, in this case the file starts with function definition like: function y = f(x) function [u,v] = f(x,y,z) • File name and the name of function in the file are usually identical, however while they are different, MATLAB use file name to call function. • If you add additional function in same M-file, it considered sub-function and might be called from inside the M-file only. Only the first function might be called from outside.
  • 25. SAVING RESULTS • We can save all our results for future reference . • The command diary ‘FileName' saves all output to command window into the FileName.txt file until this option is turned off by the command diary off • The following commands save & load the entire workspace into the file 'MyMatFile.mat' • save 'MyMatFile' • load 'MyMatFile' • save 'x.mat' x % save a specific variable • saving in ASCII format: • x = (-1:0.4:1)' ; y = sin(x*pi) • var = [x y] % double-column • save 'my_sin.dat' -ASCII -double var %Save in 16-digit ASCII format
  • 26. SIMULINK • Simulink is a simulation and model-based design environment for dynamic and embedded systems, integrated with MATLAB. Simulink, also developed by MathWorks, is a data flow graphical programming language tool for modelling, simulating and analyzing multi-domain dynamic systems. It is basically a graphical block diagramming tool with customizable set of block libraries.
  • 27. SIMULINK SUPPORTS • system-level design • simulation • automatic code generation • testing and verification of embedded systems
  • 28. APPLICATIONS OF MATLAB • Statistics and machine learning(ML) This toolbox in MATLAB can be very handy for the programmers. ... • Curve fitting. The curve fitting toolbox helps to analyze the pattern of occurrence of data. ... • Control systems. ... • Signal Processing. ... • Mapping. ... • Deep learning. ... • Financial analysis. ... • Image processing.
  • 29. USES • Signal Processing and Communications • Image and Video Processing • Control Systems • Test and Measurement • Computational Finance • Computational Biology