SlideShare a Scribd company logo
1 of 10
Introduction to MATLAB
MATLAB Environment

Current
Directory

Command Window

Command History
Entering Commands in Expressions
Lab Session 1.1
>> 20/4 (ENTER)
ans =

5.0000
The default variable ans in MATLAB
Lab Session 1.3
>> ans * 4 (ENTER)
ans =
20.0000
Using variable in MATLAB programming
Lab Session 1.4

>> a = 10;
>> b = 20;
>> c = 30;

>> d = a + b;
>> e = c – b;
d
e

Result:

d=
30.0000
e=
10.0000
Using functions in MATLAB programming
Lab Session 1.5
>> a = sqrt(100)
a=
10.0000

Exercise:
Use MATAB built-in functions for finding average of 10 numbers. Also
find minimum and maximum of 10 numbers list.
Scalar Arithmetic Operations
Symbol

Operation

MATLAB form

^

exponentiation: ab

a^b

*

multiplication: a.b

a*b

/

right division:

a b

a/b



left division:

b a

ab

+

addition:

-

subtraction

a+b

a+b

a-b

a–b
Order of preference
Precedence

Operation

First

Parenthesis, evaluated starting with the innermost
pair.

Second

Exponentiation, evaluated from left to right.

Third

Multiplication and Division with equal precedence,
evaluated from left to right

Fourth

Addition and subtraction with equal precedence,
evaluated from left to right.
Lab Session 1.6
>> 8 + 3 * 5
ans=
23
>> 8 + ( 3 * 5)
ans=
23
>> ( 8 + 3 ) * 5
ans=
55
>> 4 ^ 2 – 12 – 8 / 4 * 2
ans=
0

>> 4 ^ 2 – 12 – 8 /( 4 * 2)
ans=
3
>>3*4^2 + 5
ans=
53
>>(3*4)^2 + 5
ans=
149
>>27^(1/3) + 32^(0.2)
ans=
5
>>27^(1/3) + 32^0.2
ans=
5
>>27^1/3 + 32^0.2
ans=
11
Now do this assignment
• Use MATLAB to compute the following
expressions:

More Related Content

What's hot

Nams- Roots of equations by numerical methods
Nams- Roots of equations by numerical methodsNams- Roots of equations by numerical methods
Nams- Roots of equations by numerical methods
Ruchi Maurya
 
T testcorrel
T testcorrelT testcorrel
T testcorrel
iamkim
 

What's hot (20)

two dimensional array
two dimensional array two dimensional array
two dimensional array
 
Nams- Roots of equations by numerical methods
Nams- Roots of equations by numerical methodsNams- Roots of equations by numerical methods
Nams- Roots of equations by numerical methods
 
MATLAB
MATLABMATLAB
MATLAB
 
Soft computing lab
Soft computing labSoft computing lab
Soft computing lab
 
I need some help implementing this in java using net beans. can anyone help ...
I need some help implementing this in java using net beans. can anyone help  ...I need some help implementing this in java using net beans. can anyone help  ...
I need some help implementing this in java using net beans. can anyone help ...
 
Mbd2
Mbd2Mbd2
Mbd2
 
Applications of numerical methods
Applications of numerical methodsApplications of numerical methods
Applications of numerical methods
 
Basic concepts in_matlab
Basic concepts in_matlabBasic concepts in_matlab
Basic concepts in_matlab
 
Mit6 094 iap10_lec02
Mit6 094 iap10_lec02Mit6 094 iap10_lec02
Mit6 094 iap10_lec02
 
Lecture three
Lecture threeLecture three
Lecture three
 
Ankita sharma focp
Ankita sharma focpAnkita sharma focp
Ankita sharma focp
 
bisection method
bisection methodbisection method
bisection method
 
Matlab cheatsheet
Matlab cheatsheetMatlab cheatsheet
Matlab cheatsheet
 
T testcorrel
T testcorrelT testcorrel
T testcorrel
 
Mit6 094 iap10_lec03
Mit6 094 iap10_lec03Mit6 094 iap10_lec03
Mit6 094 iap10_lec03
 
Intro to Matlab programming
Intro to Matlab programmingIntro to Matlab programming
Intro to Matlab programming
 
Romberg’s method
Romberg’s methodRomberg’s method
Romberg’s method
 
Matlab lecture 6 – newton raphson method@taj copy
Matlab lecture 6 – newton raphson method@taj   copyMatlab lecture 6 – newton raphson method@taj   copy
Matlab lecture 6 – newton raphson method@taj copy
 
Matlab practice
Matlab practiceMatlab practice
Matlab practice
 
Bisection method in maths 4
Bisection method in maths 4Bisection method in maths 4
Bisection method in maths 4
 

Viewers also liked (6)

12 stages of production
12 stages of production 12 stages of production
12 stages of production
 
Filming
FilmingFilming
Filming
 
Planning and research
Planning and researchPlanning and research
Planning and research
 
Film industry
Film industryFilm industry
Film industry
 
Filming Session #2
Filming Session #2Filming Session #2
Filming Session #2
 
Media film industry
Media film industryMedia film industry
Media film industry
 

Similar to Introduction to matlab

MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
andreecapon
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab session
Dr. Krishna Mohbey
 

Similar to Introduction to matlab (20)

MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Programming with matlab session 1
Programming with matlab session 1Programming with matlab session 1
Programming with matlab session 1
 
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-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
Raushan's MATLB PPT..pptx
Raushan's MATLB PPT..pptxRaushan's MATLB PPT..pptx
Raushan's MATLB PPT..pptx
 
Matlab
MatlabMatlab
Matlab
 
Tutorial2
Tutorial2Tutorial2
Tutorial2
 
Introduction to Matlab.pdf
Introduction to Matlab.pdfIntroduction to Matlab.pdf
Introduction to Matlab.pdf
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
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
 
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
 
Introduction to Matlab.ppt
Introduction to Matlab.pptIntroduction to Matlab.ppt
Introduction to Matlab.ppt
 
sol43.pdf
sol43.pdfsol43.pdf
sol43.pdf
 
Matlab-1.pptx
Matlab-1.pptxMatlab-1.pptx
Matlab-1.pptx
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 

More from QUAID-E-AWAM UNIVERSITY OF ENGINEERING, SCIENCE & TECHNOLOGY, NAWABSHAH, SINDH, PAKISTAN (11)

Uml for Java Programmers
Uml for Java ProgrammersUml for Java Programmers
Uml for Java Programmers
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Java
JavaJava
Java
 
Java
JavaJava
Java
 
Java
JavaJava
Java
 
Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
Java applets
Java appletsJava applets
Java applets
 
Introduction to-java
Introduction to-javaIntroduction to-java
Introduction to-java
 
Introduction+to+java+2
Introduction+to+java+2Introduction+to+java+2
Introduction+to+java+2
 
Threads
ThreadsThreads
Threads
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

Introduction to matlab

  • 3. Entering Commands in Expressions Lab Session 1.1 >> 20/4 (ENTER) ans = 5.0000
  • 4. The default variable ans in MATLAB Lab Session 1.3 >> ans * 4 (ENTER) ans = 20.0000
  • 5. Using variable in MATLAB programming Lab Session 1.4 >> a = 10; >> b = 20; >> c = 30; >> d = a + b; >> e = c – b; d e Result: d= 30.0000 e= 10.0000
  • 6. Using functions in MATLAB programming Lab Session 1.5 >> a = sqrt(100) a= 10.0000 Exercise: Use MATAB built-in functions for finding average of 10 numbers. Also find minimum and maximum of 10 numbers list.
  • 7. Scalar Arithmetic Operations Symbol Operation MATLAB form ^ exponentiation: ab a^b * multiplication: a.b a*b / right division: a b a/b left division: b a ab + addition: - subtraction a+b a+b a-b a–b
  • 8. Order of preference Precedence Operation First Parenthesis, evaluated starting with the innermost pair. Second Exponentiation, evaluated from left to right. Third Multiplication and Division with equal precedence, evaluated from left to right Fourth Addition and subtraction with equal precedence, evaluated from left to right.
  • 9. Lab Session 1.6 >> 8 + 3 * 5 ans= 23 >> 8 + ( 3 * 5) ans= 23 >> ( 8 + 3 ) * 5 ans= 55 >> 4 ^ 2 – 12 – 8 / 4 * 2 ans= 0 >> 4 ^ 2 – 12 – 8 /( 4 * 2) ans= 3 >>3*4^2 + 5 ans= 53 >>(3*4)^2 + 5 ans= 149 >>27^(1/3) + 32^(0.2) ans= 5 >>27^(1/3) + 32^0.2 ans= 5 >>27^1/3 + 32^0.2 ans= 11
  • 10. Now do this assignment • Use MATLAB to compute the following expressions: