SlideShare a Scribd company logo
Multimedia Technology in
MATLAB
By:
Mustafa N. Jaafar
Lecture1:
MATLAB Introduction
INSTALL MATLAB R2021A
1. To install MATLAB R2021a, insert the MATLAB flash drive or extract the
downloaded .zip file, go into the Matlab for Windows folder, then double-click
on setup.exe.
STEP 2: CHOOSE TO INSTALL WITHOUT USING THE
INTERNET
STEP 3: REVIEW THE LICENSE AGREEMENT
STEP 4: SPECIFY THE FILE INSTALLATION KEY
LEAVE THE DEFAULT INSTALLATION FOLDER
LOCATION. CLICK NEXT.
LEAVE THE DEFAULT PRODUCT SELECTION.
CLICK NEXT.
Introduction to programming in MATLAB
BEGIN INSTALL
INSTALLATION COMPLETE WINDOW,
CLICK FINISH.
THE GRAPHICAL INTERFACE TO THE MATLAB WORKSPACE
USING MATLAB AS A CALCULATOR
• >> 1+2*3
ans = 7
• >> x = 1+2*3
x = 7
• >> 4*x
ans = 28.000
• >> (1+2)*3
ans = 9
• >> 1/(2+3^2)+4/5*6/7
ans = 0.7766
• >> 1/2+3^2+4/5*6/7
ans = 10.1857
OVERWRITING VARIABLE
• >> t = 5;
• >> t = t+1
• t = 6
ERROR MESSAGES
• >> x = 10;
• >> 5x
• ??? 5x
• |
• Error: Unexpected MATLAB
expression.
MANAGING THE WORKSPACE
• >> clear
The command clear or clear all
removes all variables from the
workspace. This frees up system
memory. In order to display a list of the
variables currently in the memory, type
GETTING HELP
• >> help sqrt • In the current version
the doc function opens the on-line
version of the help manual. This is
very helpful for more complex
commands.
MATHEMATICAL FUNCTIONS
VECTOR GENERATION
• For example, to enter a row vector, v, type
>> v = [1 4 7 10 13]
v = 1 4 7 10 13
• Column vectors are created in a similar way, however, semicolon (;) must separate the components of
a column vector,
>> w = [1;4;7;10;13]
w =
1
4
7
10
13
VECTOR GENERATION
• transpose operator. The transpose operation is denoted by an apostrophe or a single quote (’).
>> w = v
’ w =
1
4
7
10
13
• o access blocks of elements, we use MATLAB’s colon notation (:). For example, to access the first
three elements of v, we write
>> v(1:3)
ans = 1 4 7
ENTERING A MATRIX
• A matrix is an array of numbers. To type a matrix into MATLAB you must
• begin with a square bracket, [
• separate elements in a row with spaces or commas (,)
• use a semicolon (;) to separate rows
• end the matrix with another square bracket, ]. 20
• We can then view a particular element in a matrix by specifying its
location. We write,
>> A(2,1)
• ans = 4
DELETING ROW OR COLUMN
• To delete a row or column of a
matrix, use the empty vector
operator, [ ].
>> A(3,:) = []
A = 1 2 3 4 5 6
DIMENSION
• To determine the dimensions of a
matrix or vector, use the command
size. For example,
>> size(A)
ans = 3 3
ARRAY OPERATIONS
• As we mentioned earlier, MATLAB allows arithmetic operations: +, −, ∗, and ˆ to be carried out
on matrices.Thus,
A+B or B+A  is valid if A and B are of the same size
A*B  is valid if A’s number of column equals B’s number of rows
A^2  is valid if A is square and equals A*A
α*A or A*α  multiplies each element of A by α
.*  Element-by-element multiplication
./  Element-by-element division
.^  Element-by-element exponentiation
SUMMARY OF MATRIX AND ARRAY OPERATIONS
INTRODUCTION TO PROGRAMMING IN MATLAB
• Therefore, a different way of executing repeatedly commands with MATLAB is:
1. to create a file with a list of commands,
2. 2. save the file, and
3. 3. run the file.
• If needed, corrections or changes can be made to the commands in the file. The
files that are used for this purpose are called script files or scripts for short.
This section covers the following topics:
• M-File Scripts
• M-File Functions
CONTROL FLOW
• The ‘‘if...end’’ structure
• MATLAB supports the variants of “if” construct.
• if ... End
• if ... else ... end
• if ... elseif ... else ... end
THE ‘‘FOR...END’’ LOOP
• n the for ... end loop, the execution of a command is repeated at a fixed and
predetermined number of times. The syntax is
for variable = expression
statements
end
• Example
for ii=1:5
x=ii*ii
end
THE ‘‘WHILE...END’’
• loop This loop is used when the number of passes is not specified. The looping continues until a stated
condition is satisfied. The while loop has the form:
while expression
statements
end
• The statements are executed as long as expression is true.
x = 1
while x <= 10
x = 3*x
end
REFERENCE
• https://www.mathworks.com/?s_tid=gn_logo
• Houcque, David. "Introduction to Matlab for engineering students." Northwestern
University 1 (2005).

More Related Content

PPTX
My lectures circular queue
PPTX
Lecture 1 oop
PDF
An Introduction to Python Programming
PPTX
BASIC SLICING AND ADVANCED INDEXING IN NUMPY.pptx
PPTX
Packages In Python Tutorial
PPTX
Generators In Python
PDF
Algorithms Lecture 3: Analysis of Algorithms II
My lectures circular queue
Lecture 1 oop
An Introduction to Python Programming
BASIC SLICING AND ADVANCED INDEXING IN NUMPY.pptx
Packages In Python Tutorial
Generators In Python
Algorithms Lecture 3: Analysis of Algorithms II

What's hot (20)

PDF
Set methods in python
PPT
Exception handling and function in python
PPTX
Compare between pop and oop
PPTX
Two dimensional arrays
PDF
Optimal binary search tree
PPTX
Unit i basic concepts of algorithms
PPTX
Connectivity of graphs
PPTX
DataSructure-Time and Space Complexity.pptx
PPTX
Collision in Hashing.pptx
PPTX
PDF
DATA VISUALIZATION USING MATPLOTLIB (PYTHON)
PPTX
Normalisation
PPTX
Python: Basic Inheritance
PDF
Python libraries
DOCX
Python Applications
PPT
Python List.ppt
PPTX
USE OF PRINT IN PYTHON PART 2
PDF
Analysis and design of algorithms part 4
PPTX
Intro to Python Programming Language
Set methods in python
Exception handling and function in python
Compare between pop and oop
Two dimensional arrays
Optimal binary search tree
Unit i basic concepts of algorithms
Connectivity of graphs
DataSructure-Time and Space Complexity.pptx
Collision in Hashing.pptx
DATA VISUALIZATION USING MATPLOTLIB (PYTHON)
Normalisation
Python: Basic Inheritance
Python libraries
Python Applications
Python List.ppt
USE OF PRINT IN PYTHON PART 2
Analysis and design of algorithms part 4
Intro to Python Programming Language
Ad

Similar to Introduction to programming in MATLAB (20)

PDF
Matlab guide
PPTX
TRAINING PROGRAMME ON MATLAB ASSOCIATE EXAM (1).pptx
PPTX
Introduction to scientific computing with matlab.pptx
PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
PPTX
From zero to MATLAB hero: Mastering the basics and beyond
PPT
Introduction to Matlab.ppt
PDF
EE6711 Power System Simulation Lab manual
PPT
Matlab practical and lab session
PDF
Introduction to Matlab.pdf
PDF
Matlab Tutorial for Beginners - I
PPT
MatlabIntro (1).ppt
PDF
MATLAB INTRODUCTION
PPT
Matlab Tutorial.ppt
PDF
Matlab lec1
PPTX
Introduction to matlab
PDF
PDF
interfacing matlab with embedded systems
PDF
A complete introduction on matlab and matlab's projects
Matlab guide
TRAINING PROGRAMME ON MATLAB ASSOCIATE EXAM (1).pptx
Introduction to scientific computing with matlab.pptx
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
From zero to MATLAB hero: Mastering the basics and beyond
Introduction to Matlab.ppt
EE6711 Power System Simulation Lab manual
Matlab practical and lab session
Introduction to Matlab.pdf
Matlab Tutorial for Beginners - I
MatlabIntro (1).ppt
MATLAB INTRODUCTION
Matlab Tutorial.ppt
Matlab lec1
Introduction to matlab
interfacing matlab with embedded systems
A complete introduction on matlab and matlab's projects
Ad

Recently uploaded (20)

PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
01-Introduction-to-Information-Management.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharma ospi slides which help in ospi learning
PDF
A systematic review of self-coping strategies used by university students to ...
O7-L3 Supply Chain Operations - ICLT Program
Microbial disease of the cardiovascular and lymphatic systems
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Microbial diseases, their pathogenesis and prophylaxis
01-Introduction-to-Information-Management.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Chinmaya Tiranga quiz Grand Finale.pdf
Final Presentation General Medicine 03-08-2024.pptx
Supply Chain Operations Speaking Notes -ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Complications of Minimal Access Surgery at WLH
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharma ospi slides which help in ospi learning
A systematic review of self-coping strategies used by university students to ...

Introduction to programming in MATLAB

  • 1. Multimedia Technology in MATLAB By: Mustafa N. Jaafar Lecture1: MATLAB Introduction
  • 2. INSTALL MATLAB R2021A 1. To install MATLAB R2021a, insert the MATLAB flash drive or extract the downloaded .zip file, go into the Matlab for Windows folder, then double-click on setup.exe.
  • 3. STEP 2: CHOOSE TO INSTALL WITHOUT USING THE INTERNET
  • 4. STEP 3: REVIEW THE LICENSE AGREEMENT
  • 5. STEP 4: SPECIFY THE FILE INSTALLATION KEY
  • 6. LEAVE THE DEFAULT INSTALLATION FOLDER LOCATION. CLICK NEXT.
  • 7. LEAVE THE DEFAULT PRODUCT SELECTION. CLICK NEXT.
  • 11. THE GRAPHICAL INTERFACE TO THE MATLAB WORKSPACE
  • 12. USING MATLAB AS A CALCULATOR • >> 1+2*3 ans = 7 • >> x = 1+2*3 x = 7 • >> 4*x ans = 28.000 • >> (1+2)*3 ans = 9 • >> 1/(2+3^2)+4/5*6/7 ans = 0.7766 • >> 1/2+3^2+4/5*6/7 ans = 10.1857
  • 13. OVERWRITING VARIABLE • >> t = 5; • >> t = t+1 • t = 6 ERROR MESSAGES • >> x = 10; • >> 5x • ??? 5x • | • Error: Unexpected MATLAB expression.
  • 14. MANAGING THE WORKSPACE • >> clear The command clear or clear all removes all variables from the workspace. This frees up system memory. In order to display a list of the variables currently in the memory, type GETTING HELP • >> help sqrt • In the current version the doc function opens the on-line version of the help manual. This is very helpful for more complex commands.
  • 16. VECTOR GENERATION • For example, to enter a row vector, v, type >> v = [1 4 7 10 13] v = 1 4 7 10 13 • Column vectors are created in a similar way, however, semicolon (;) must separate the components of a column vector, >> w = [1;4;7;10;13] w = 1 4 7 10 13
  • 17. VECTOR GENERATION • transpose operator. The transpose operation is denoted by an apostrophe or a single quote (’). >> w = v ’ w = 1 4 7 10 13 • o access blocks of elements, we use MATLAB’s colon notation (:). For example, to access the first three elements of v, we write >> v(1:3) ans = 1 4 7
  • 18. ENTERING A MATRIX • A matrix is an array of numbers. To type a matrix into MATLAB you must • begin with a square bracket, [ • separate elements in a row with spaces or commas (,) • use a semicolon (;) to separate rows • end the matrix with another square bracket, ]. 20 • We can then view a particular element in a matrix by specifying its location. We write, >> A(2,1) • ans = 4
  • 19. DELETING ROW OR COLUMN • To delete a row or column of a matrix, use the empty vector operator, [ ]. >> A(3,:) = [] A = 1 2 3 4 5 6 DIMENSION • To determine the dimensions of a matrix or vector, use the command size. For example, >> size(A) ans = 3 3
  • 20. ARRAY OPERATIONS • As we mentioned earlier, MATLAB allows arithmetic operations: +, −, ∗, and ˆ to be carried out on matrices.Thus, A+B or B+A  is valid if A and B are of the same size A*B  is valid if A’s number of column equals B’s number of rows A^2  is valid if A is square and equals A*A α*A or A*α  multiplies each element of A by α .*  Element-by-element multiplication ./  Element-by-element division .^  Element-by-element exponentiation
  • 21. SUMMARY OF MATRIX AND ARRAY OPERATIONS
  • 22. INTRODUCTION TO PROGRAMMING IN MATLAB • Therefore, a different way of executing repeatedly commands with MATLAB is: 1. to create a file with a list of commands, 2. 2. save the file, and 3. 3. run the file. • If needed, corrections or changes can be made to the commands in the file. The files that are used for this purpose are called script files or scripts for short. This section covers the following topics: • M-File Scripts • M-File Functions
  • 23. CONTROL FLOW • The ‘‘if...end’’ structure • MATLAB supports the variants of “if” construct. • if ... End • if ... else ... end • if ... elseif ... else ... end
  • 24. THE ‘‘FOR...END’’ LOOP • n the for ... end loop, the execution of a command is repeated at a fixed and predetermined number of times. The syntax is for variable = expression statements end • Example for ii=1:5 x=ii*ii end
  • 25. THE ‘‘WHILE...END’’ • loop This loop is used when the number of passes is not specified. The looping continues until a stated condition is satisfied. The while loop has the form: while expression statements end • The statements are executed as long as expression is true. x = 1 while x <= 10 x = 3*x end
  • 26. REFERENCE • https://www.mathworks.com/?s_tid=gn_logo • Houcque, David. "Introduction to Matlab for engineering students." Northwestern University 1 (2005).