SlideShare a Scribd company logo
1 of 41
11
Introduction to MATLAB
Lecture Series - 1
by
Shameer Koya
2
Topics..
 What is MATLAB ??
 Basic Matrix Operations
 Complex Number Operations
 Matrices and Arrays
 Polynomials
 Script Files and M-files
 Some more Operations and Functions
APPLICATIONS:
 Plotting functions ..
 Electrical Applications ..
3
What is MATLAB ??
 MATLAB stands for Matrix Laboratory.
 Matlab had many functions and toolboxes to help in various
applications
 It allows you to solve many technical computing problems,
especially those with matrix and vector formulas, in a
fraction of the time it would take to write a program in a
scalar non-interactive language such as C or Fortran.
 It also contains functions for 2-D and 3-D graphics and
animation.
4
MATLAB
Everything in MATLAB is a matrix !
5
MATLAB
 The MATLAB environment is command oriented
somewhat like UNIX. A prompt appears on the screen and
a MATLAB statement can be entered. When the <ENTER>
key is pressed, the statement is executed, and another
prompt appears.
 If a statement is terminated with a semicolon ( ; ), no
results will be displayed. Otherwise results will appear
before the next prompt.
6
The MATLAB User Interface
MATLAB
Command
Window
File
Edit
View
View
View
Web
MATLAB GUI – Current Directory
 Setting the path:
 You need to set up what directory to
save your files to
 Multiple options: directory
commands, current directory path,
current directory window
 Directory commands: pwd, cd,
dir, ls, path, editpath,
copyfile, mkdir
 When in doubt, check your
path
MATLAB GUI – Command Window
MATLAB GUI – Workspace
MATLAB GUI – Variable Editor
MATLAB GUI – Command History
MATLAB GUI – Additional Windows
 Editor window
 Will discuss with scripts and functions
 Figure window
 Will discuss with graphics
MATLAB Help
 Three common ways to access:
 Type help topic at command line
 Select help from drop-down menus (opens help window)
 Mathworks website
 help, helpwin, helpdesk
 MATLAB help is very comprehensive
Help
Arrays and Matrices
 MATLAB is designed for use with matrices, so many
functions are optimized for matrix use
 This will be discussed further next week
25
MATLAB Variable Names
 Variable names ARE case sensitive
 Variable names can contain up to 63 characters (as of MATLAB 6.5 and
newer)
 Variable names must start with a letter followed by letters, digits, and
underscores.
 Can contain any combination of letters, digits, and underscores
 Special functions that are already defined, but can be overwritten
(temporarily)
pi, i, j, eps, realmin, realmax, Inf, NaN
 Don’t use function names
Namelength max, which –all var_name, isvarname
Variables – Types
 Numeric
 Logical
 Strings and Character (discussed further with file
I/O)
 Cell arrays and structures (discussed further with file
I/O)
 Function handles (discussed further with graphics)
27
MATLAB 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 and j i = j = square root of -1
realmin The smallest usable positive real number
realmax The largest usable positive real number
Variables …..
 To recall the variable
» D
D =
2
 Use arrow keys for scrolling through previous commands
 List of variables in the workspace
» who
D b a ans
 To clear varibles
» clear D
» clear
28
29
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)
Order of Operations
 Standard order of operations is enforced in MATLAB
 Parentheses
 Exponentiation
 Multiplication and Division
 Addition and Subtraction
 When in doubt, add parentheses
 MATLAB can help you keep track of ()
31
Other MATLAB 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
32
MATLAB Relational Operators
 MATLAB supports six relational operators.
Less Than <
Less Than or Equal <=
Greater Than >
Greater Than or Equal >=
Equal To ==
Not Equal To ~=
33
MATLAB Logical Operators
 MATLAB supports three logical operators.
not ~ % highest precedence
and & % equal precedence with or
or | % equal precedence with and
Logical Operations
 &, |, ~, xor
 &&, ||
35
Simple Math
» a=5;
» b=a/2
b =
2.5000
» 2+2.5+106
ans =
110.5000
» 4*25 + 2^3
ans =
108
Built-in Functions
36
Trigonometric
functions
sin, cos, tan, sin, acos, atan,
sinh, cosh, tanh, asinh,
acosh, atanh, csc, sec, cot,
acsc, …
Exponential
functions
exp, log, log10, sqrt
Complex
functions
abs, angle, imag, real, conj
Rounding and
Remainder
functions
floor, ceil, round, mod, rem,
sign
37
Numbers and variables and similar in
Matlab
 Smallest positive floating point number 2.2251e-308,
and the highest is 1.7977e+308.
 Spacing of floating point numbers (calculation precision)
is 2.2204e-016.
 1/0 gives infinite - Inf.
 0/0 or Inf-Inf gives NaN – (not-a-number).
 Matlab is case sensitive; a =10 is not equal to A=10.
 If the command is concluded with semicolon, the result
will not be shown on the screen.
 For decimal numbers, dot is used, for example 2.45.
 Formats: format short, format long, fomat long
e...format.
 % Comment.
38
Numbers and variables and similar in
Matlab
 2.4e-12 is 2.4*10-12
 pi is the variable with defined name.
 i or j is complex unit (it can be overwritten).
 For trigonometric functions [rad] is used.
 clear all, clears all defined variables.
 close all, closes all graphical windows.
 clear all, close all, very usefull combination!
 clc, clears the screen, but nothing else.
 CRTL+C stop the execution of the program in Matlab.
 dir, current directory.
 who, list of all defined variables.
Basic Matlab Operations
>> % This is a comment, it starts with a “%”
>> y = 5*3 + 2^2; % simple arithmetic
>> x = [1 2 4 5 6]; % create the vector “x”
>> x1 = x.^2; % square each element in x
>> E = sum(abs(x).^2); % Calculate signal energy
>> P = E/length(x); % Calculate av signal power
>> x2 = x(1:3); % Select first 3 elements in x
>> z = 1+i; % Create a complex number
>> a = real(z); % Pick off real part
>> b = imag(z); % Pick off imaginary part
Basic Matlab Operations …
>> plot(x); % Plot the vector as a signal
>> t = 0:0.1:100; % Generate sampled time
>> x3=exp(-t).*cos(t); % Generate a discrete signal
>> plot(t, x3, ‘x’); % Plot points
>> x=sqrt(2)/2 % Built in functions
>> y=sin(x) % Trigonometric functions
40
41
Thanks
Questions ??

More Related Content

What's hot

Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabBilawalBaloch1
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlabaman gupta
 
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 4Randa Elanwar
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to MatlabAmr Rashed
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab sessionDr. Krishna Mohbey
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMohd Esa
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabTarun Gehlot
 
Basic matlab and matrix
Basic matlab and matrixBasic matlab and matrix
Basic matlab and matrixSaidur Rahman
 
Basic operators in matlab
Basic operators in matlabBasic operators in matlab
Basic operators in matlabrishiteta
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to MatlabTariq kanher
 
MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1Elaf A.Saeed
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsRay Phan
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabMohan Raj
 
Matlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - IMatlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - IVijay Kumar Gupta
 
Matlab Overviiew
Matlab OverviiewMatlab Overviiew
Matlab OverviiewNazim Naeem
 

What's hot (20)

Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
Matlab Basic Tutorial
Matlab Basic TutorialMatlab Basic Tutorial
Matlab Basic Tutorial
 
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
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab session
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Matlab-fundamentals of matlab-1
Matlab-fundamentals of matlab-1Matlab-fundamentals of matlab-1
Matlab-fundamentals of matlab-1
 
Basic matlab and matrix
Basic matlab and matrixBasic matlab and matrix
Basic matlab and matrix
 
Basic operators in matlab
Basic operators in matlabBasic operators in matlab
Basic operators in matlab
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & Scientists
 
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
 
Matlab Overviiew
Matlab OverviiewMatlab Overviiew
Matlab Overviiew
 
Matlab basic and image
Matlab basic and imageMatlab basic and image
Matlab basic and image
 

Viewers also liked

Matlab ploting
Matlab plotingMatlab ploting
Matlab plotingAmeen San
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arraysAmeen San
 
Matlab m files and scripts
Matlab m files and scriptsMatlab m files and scripts
Matlab m files and scriptsAmeen San
 
Matlab complex numbers
Matlab complex numbersMatlab complex numbers
Matlab complex numbersAmeen San
 
Microprocessor and Microcontroller lec4
Microprocessor and Microcontroller lec4Microprocessor and Microcontroller lec4
Microprocessor and Microcontroller lec4Ameen San
 
Matlab dc circuit analysis
Matlab dc circuit analysisMatlab dc circuit analysis
Matlab dc circuit analysisAmeen San
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fittingAmeen San
 
Microprocessor and Microcontroller lec5
Microprocessor and Microcontroller lec5Microprocessor and Microcontroller lec5
Microprocessor and Microcontroller lec5Ameen San
 
Plc analog input output programming
Plc analog input output programmingPlc analog input output programming
Plc analog input output programmingEngr Alam
 
Plc analog Tutorial
Plc analog TutorialPlc analog Tutorial
Plc analog TutorialElectro 8
 
Matlab dc motor modeling
Matlab dc motor modelingMatlab dc motor modeling
Matlab dc motor modelingAmeen San
 
Matlab simpowersystem
Matlab simpowersystemMatlab simpowersystem
Matlab simpowersystemAmeen San
 
Mat lab solving equations simulink
Mat lab solving equations simulinkMat lab solving equations simulink
Mat lab solving equations simulinkAmeen San
 
Matlab solving rlc circuit
Matlab solving rlc circuitMatlab solving rlc circuit
Matlab solving rlc circuitAmeen San
 
PLC input and output devices
PLC input and output devices PLC input and output devices
PLC input and output devices Ameen San
 
Application of Capacitors to Distribution System and Voltage Regulation
Application of Capacitors to Distribution System and Voltage RegulationApplication of Capacitors to Distribution System and Voltage Regulation
Application of Capacitors to Distribution System and Voltage RegulationAmeen San
 
Matlab simulink introduction
Matlab simulink introductionMatlab simulink introduction
Matlab simulink introductionAmeen San
 
PLC Programming Languages
PLC Programming LanguagesPLC Programming Languages
PLC Programming LanguagesLIJU. G. CHACKO
 

Viewers also liked (20)

Matlab ploting
Matlab plotingMatlab ploting
Matlab ploting
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arrays
 
Matlab m files and scripts
Matlab m files and scriptsMatlab m files and scripts
Matlab m files and scripts
 
Matlab complex numbers
Matlab complex numbersMatlab complex numbers
Matlab complex numbers
 
Introto pl cs
Introto pl csIntroto pl cs
Introto pl cs
 
Microprocessor and Microcontroller lec4
Microprocessor and Microcontroller lec4Microprocessor and Microcontroller lec4
Microprocessor and Microcontroller lec4
 
Matlab dc circuit analysis
Matlab dc circuit analysisMatlab dc circuit analysis
Matlab dc circuit analysis
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fitting
 
Microprocessor and Microcontroller lec5
Microprocessor and Microcontroller lec5Microprocessor and Microcontroller lec5
Microprocessor and Microcontroller lec5
 
Plc analog input output programming
Plc analog input output programmingPlc analog input output programming
Plc analog input output programming
 
Plc analog Tutorial
Plc analog TutorialPlc analog Tutorial
Plc analog Tutorial
 
Chapter 2 ladder
Chapter 2 ladderChapter 2 ladder
Chapter 2 ladder
 
Matlab dc motor modeling
Matlab dc motor modelingMatlab dc motor modeling
Matlab dc motor modeling
 
Matlab simpowersystem
Matlab simpowersystemMatlab simpowersystem
Matlab simpowersystem
 
Mat lab solving equations simulink
Mat lab solving equations simulinkMat lab solving equations simulink
Mat lab solving equations simulink
 
Matlab solving rlc circuit
Matlab solving rlc circuitMatlab solving rlc circuit
Matlab solving rlc circuit
 
PLC input and output devices
PLC input and output devices PLC input and output devices
PLC input and output devices
 
Application of Capacitors to Distribution System and Voltage Regulation
Application of Capacitors to Distribution System and Voltage RegulationApplication of Capacitors to Distribution System and Voltage Regulation
Application of Capacitors to Distribution System and Voltage Regulation
 
Matlab simulink introduction
Matlab simulink introductionMatlab simulink introduction
Matlab simulink introduction
 
PLC Programming Languages
PLC Programming LanguagesPLC Programming Languages
PLC Programming Languages
 

Similar to Matlab introduction

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 beyondMahuaPal6
 
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxMATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxprashantkumarchinama
 
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 projectsMukesh Kumar
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013amanabr
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Kurmendra Singh
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systemsRaghav Shetty
 
Introduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdfIntroduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdfDrAzizulHasan1
 
Kevin merchantss
Kevin merchantssKevin merchantss
Kevin merchantssdharmesh69
 
KEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENTKEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENTtejas1235
 

Similar to Matlab introduction (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 tut2
Matlab tut2Matlab tut2
Matlab tut2
 
Matlab anilkumar
Matlab  anilkumarMatlab  anilkumar
Matlab anilkumar
 
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxMATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
 
Matlab summary
Matlab summaryMatlab summary
Matlab summary
 
Introduction to Matlab.ppt
Introduction to Matlab.pptIntroduction to Matlab.ppt
Introduction to Matlab.ppt
 
Matlab
MatlabMatlab
Matlab
 
Ch1
Ch1Ch1
Ch1
 
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
 
MatlabIntro (1).ppt
MatlabIntro (1).pptMatlabIntro (1).ppt
MatlabIntro (1).ppt
 
Matlab guide
Matlab guideMatlab guide
Matlab guide
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Basic matlab for beginners
Basic matlab for beginnersBasic matlab for beginners
Basic matlab for beginners
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
 
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 for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdfIntroduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdf
 
Kevin merchantss
Kevin merchantssKevin merchantss
Kevin merchantss
 
KEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENTKEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENT
 
1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx
 

More from Ameen San

Distribution System Voltage Drop and Power Loss Calculation
Distribution System Voltage Drop and Power Loss CalculationDistribution System Voltage Drop and Power Loss Calculation
Distribution System Voltage Drop and Power Loss CalculationAmeen San
 
Load Characteristics
Load CharacteristicsLoad Characteristics
Load CharacteristicsAmeen San
 
ELECTRICAL DISTRIBUTION TECHNOLOGY
ELECTRICAL DISTRIBUTION TECHNOLOGYELECTRICAL DISTRIBUTION TECHNOLOGY
ELECTRICAL DISTRIBUTION TECHNOLOGYAmeen San
 
Stepper motor
Stepper motor Stepper motor
Stepper motor Ameen San
 
PLC application
PLC applicationPLC application
PLC applicationAmeen San
 
PLC arithmatic functions
PLC arithmatic functionsPLC arithmatic functions
PLC arithmatic functionsAmeen San
 
PLC data types and addressing
PLC data types and addressingPLC data types and addressing
PLC data types and addressingAmeen San
 
PLC Counters
PLC CountersPLC Counters
PLC CountersAmeen San
 
PLC Traffic Light Control
PLC Traffic Light ControlPLC Traffic Light Control
PLC Traffic Light ControlAmeen San
 
PLC Internal Relays
PLC Internal RelaysPLC Internal Relays
PLC Internal RelaysAmeen San
 
PLC Intro to programming
PLC Intro to programmingPLC Intro to programming
PLC Intro to programmingAmeen San
 
PLC Logic Circuits
PLC Logic CircuitsPLC Logic Circuits
PLC Logic CircuitsAmeen San
 
PLC Applications
PLC ApplicationsPLC Applications
PLC ApplicationsAmeen San
 
Protection Devices and the Lightning
Protection Devices and the LightningProtection Devices and the Lightning
Protection Devices and the LightningAmeen San
 
Circuit Breakers
Circuit BreakersCircuit Breakers
Circuit BreakersAmeen San
 
Engineering Economy
Engineering EconomyEngineering Economy
Engineering EconomyAmeen San
 
Accounting & financial decisions
Accounting & financial decisionsAccounting & financial decisions
Accounting & financial decisionsAmeen San
 

More from Ameen San (20)

Distribution System Voltage Drop and Power Loss Calculation
Distribution System Voltage Drop and Power Loss CalculationDistribution System Voltage Drop and Power Loss Calculation
Distribution System Voltage Drop and Power Loss Calculation
 
Load Characteristics
Load CharacteristicsLoad Characteristics
Load Characteristics
 
ELECTRICAL DISTRIBUTION TECHNOLOGY
ELECTRICAL DISTRIBUTION TECHNOLOGYELECTRICAL DISTRIBUTION TECHNOLOGY
ELECTRICAL DISTRIBUTION TECHNOLOGY
 
Stepper motor
Stepper motor Stepper motor
Stepper motor
 
PLC application
PLC applicationPLC application
PLC application
 
PLC arithmatic functions
PLC arithmatic functionsPLC arithmatic functions
PLC arithmatic functions
 
PLC data types and addressing
PLC data types and addressingPLC data types and addressing
PLC data types and addressing
 
PLC Counters
PLC CountersPLC Counters
PLC Counters
 
PLC Traffic Light Control
PLC Traffic Light ControlPLC Traffic Light Control
PLC Traffic Light Control
 
PLC Timers
PLC TimersPLC Timers
PLC Timers
 
PLC Internal Relays
PLC Internal RelaysPLC Internal Relays
PLC Internal Relays
 
PLC Intro to programming
PLC Intro to programmingPLC Intro to programming
PLC Intro to programming
 
PLC Logic Circuits
PLC Logic CircuitsPLC Logic Circuits
PLC Logic Circuits
 
PLC Applications
PLC ApplicationsPLC Applications
PLC Applications
 
Protection Devices and the Lightning
Protection Devices and the LightningProtection Devices and the Lightning
Protection Devices and the Lightning
 
Protection
ProtectionProtection
Protection
 
Relays
RelaysRelays
Relays
 
Circuit Breakers
Circuit BreakersCircuit Breakers
Circuit Breakers
 
Engineering Economy
Engineering EconomyEngineering Economy
Engineering Economy
 
Accounting & financial decisions
Accounting & financial decisionsAccounting & financial decisions
Accounting & financial decisions
 

Recently uploaded

Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 

Recently uploaded (20)

Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 

Matlab introduction

  • 1. 11 Introduction to MATLAB Lecture Series - 1 by Shameer Koya
  • 2. 2 Topics..  What is MATLAB ??  Basic Matrix Operations  Complex Number Operations  Matrices and Arrays  Polynomials  Script Files and M-files  Some more Operations and Functions APPLICATIONS:  Plotting functions ..  Electrical Applications ..
  • 3. 3 What is MATLAB ??  MATLAB stands for Matrix Laboratory.  Matlab had many functions and toolboxes to help in various applications  It allows you to solve many technical computing problems, especially those with matrix and vector formulas, in a fraction of the time it would take to write a program in a scalar non-interactive language such as C or Fortran.  It also contains functions for 2-D and 3-D graphics and animation.
  • 5. 5 MATLAB  The MATLAB environment is command oriented somewhat like UNIX. A prompt appears on the screen and a MATLAB statement can be entered. When the <ENTER> key is pressed, the statement is executed, and another prompt appears.  If a statement is terminated with a semicolon ( ; ), no results will be displayed. Otherwise results will appear before the next prompt.
  • 6. 6 The MATLAB User Interface
  • 10. View
  • 11. View
  • 12. View
  • 13. Web
  • 14. MATLAB GUI – Current Directory  Setting the path:  You need to set up what directory to save your files to  Multiple options: directory commands, current directory path, current directory window  Directory commands: pwd, cd, dir, ls, path, editpath, copyfile, mkdir  When in doubt, check your path
  • 15. MATLAB GUI – Command Window
  • 16. MATLAB GUI – Workspace
  • 17. MATLAB GUI – Variable Editor
  • 18. MATLAB GUI – Command History
  • 19. MATLAB GUI – Additional Windows  Editor window  Will discuss with scripts and functions  Figure window  Will discuss with graphics
  • 20. MATLAB Help  Three common ways to access:  Type help topic at command line  Select help from drop-down menus (opens help window)  Mathworks website  help, helpwin, helpdesk  MATLAB help is very comprehensive
  • 21. Help
  • 22.
  • 23.
  • 24. Arrays and Matrices  MATLAB is designed for use with matrices, so many functions are optimized for matrix use  This will be discussed further next week
  • 25. 25 MATLAB Variable Names  Variable names ARE case sensitive  Variable names can contain up to 63 characters (as of MATLAB 6.5 and newer)  Variable names must start with a letter followed by letters, digits, and underscores.  Can contain any combination of letters, digits, and underscores  Special functions that are already defined, but can be overwritten (temporarily) pi, i, j, eps, realmin, realmax, Inf, NaN  Don’t use function names Namelength max, which –all var_name, isvarname
  • 26. Variables – Types  Numeric  Logical  Strings and Character (discussed further with file I/O)  Cell arrays and structures (discussed further with file I/O)  Function handles (discussed further with graphics)
  • 27. 27 MATLAB 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 and j i = j = square root of -1 realmin The smallest usable positive real number realmax The largest usable positive real number
  • 28. Variables …..  To recall the variable » D D = 2  Use arrow keys for scrolling through previous commands  List of variables in the workspace » who D b a ans  To clear varibles » clear D » clear 28
  • 29. 29 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)
  • 30. Order of Operations  Standard order of operations is enforced in MATLAB  Parentheses  Exponentiation  Multiplication and Division  Addition and Subtraction  When in doubt, add parentheses  MATLAB can help you keep track of ()
  • 31. 31 Other MATLAB 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
  • 32. 32 MATLAB Relational Operators  MATLAB supports six relational operators. Less Than < Less Than or Equal <= Greater Than > Greater Than or Equal >= Equal To == Not Equal To ~=
  • 33. 33 MATLAB Logical Operators  MATLAB supports three logical operators. not ~ % highest precedence and & % equal precedence with or or | % equal precedence with and
  • 34. Logical Operations  &, |, ~, xor  &&, ||
  • 35. 35 Simple Math » a=5; » b=a/2 b = 2.5000 » 2+2.5+106 ans = 110.5000 » 4*25 + 2^3 ans = 108
  • 36. Built-in Functions 36 Trigonometric functions sin, cos, tan, sin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, csc, sec, cot, acsc, … Exponential functions exp, log, log10, sqrt Complex functions abs, angle, imag, real, conj Rounding and Remainder functions floor, ceil, round, mod, rem, sign
  • 37. 37 Numbers and variables and similar in Matlab  Smallest positive floating point number 2.2251e-308, and the highest is 1.7977e+308.  Spacing of floating point numbers (calculation precision) is 2.2204e-016.  1/0 gives infinite - Inf.  0/0 or Inf-Inf gives NaN – (not-a-number).  Matlab is case sensitive; a =10 is not equal to A=10.  If the command is concluded with semicolon, the result will not be shown on the screen.  For decimal numbers, dot is used, for example 2.45.  Formats: format short, format long, fomat long e...format.  % Comment.
  • 38. 38 Numbers and variables and similar in Matlab  2.4e-12 is 2.4*10-12  pi is the variable with defined name.  i or j is complex unit (it can be overwritten).  For trigonometric functions [rad] is used.  clear all, clears all defined variables.  close all, closes all graphical windows.  clear all, close all, very usefull combination!  clc, clears the screen, but nothing else.  CRTL+C stop the execution of the program in Matlab.  dir, current directory.  who, list of all defined variables.
  • 39. Basic Matlab Operations >> % This is a comment, it starts with a “%” >> y = 5*3 + 2^2; % simple arithmetic >> x = [1 2 4 5 6]; % create the vector “x” >> x1 = x.^2; % square each element in x >> E = sum(abs(x).^2); % Calculate signal energy >> P = E/length(x); % Calculate av signal power >> x2 = x(1:3); % Select first 3 elements in x >> z = 1+i; % Create a complex number >> a = real(z); % Pick off real part >> b = imag(z); % Pick off imaginary part
  • 40. Basic Matlab Operations … >> plot(x); % Plot the vector as a signal >> t = 0:0.1:100; % Generate sampled time >> x3=exp(-t).*cos(t); % Generate a discrete signal >> plot(t, x3, ‘x’); % Plot points >> x=sqrt(2)/2 % Built in functions >> y=sin(x) % Trigonometric functions 40