SlideShare a Scribd company logo
Logical Vectors and
      Strings
• TYPE as it is in Command Line :
   r=1; Chk result
  r<=.5
   ( Result is 0)
   and then at last
   r>=.5
( Result is 1)

Now Enter the Following statement :

r = 1:5;
r<=3

U get 11100 as statement is true for first 3 elements
• Vectors are compared element by element
  and the resulting vector is called as Logical
  Vector. It is one of the most power concepts in
  MATLAB.

• For eg try this :
a=1:5;
b=[0 2 3 5 6];
a==b % no semicolon (Result is :
0 1 1 0 0)
• Applications :
Discontinuous Graphs :




Type these Statements :
x=0:pi/20:3*pi;
y=sin(x);
y=y .* (y>0);
plot(x,y)
• What was the Funda ???
y>0 returns a logical vector with ones where sin(x)
  is positive as y>0 means it is checked element
  by element if it is >0 ; and if it is not then it
  returns 0.

After this we multiply by y to get the graph
• Avoid division by 0




As one of the element of x is exact zero.
• Use Logical Vector to replace zero with eps.




What is eps?
• This MATLAB function returns the difference
  between 1.0 and the next largest number which
  can be represented in MATLAB, i.e.
  approximately 2.2e-16.
• So you type and get :
Logical vectors
• Logical Functions :
x is a vector :
Try these statements :

x=1:5
any(x)

any(x) : returns scalar 1 in ans if any element of x
  is nonzero.
• Try for the o/p of
 x = [ 0 0]
any(x)

all(x)
Returns scalar 1 if all elements of vector x r non
   zero!
x=1:5;
all(x)
Try to get info abt all logic functions
Logical vectors
• Strings :
• For Basic i/p o/p of string we have :

name = input( 'Enter your surname: ', 's' );

Chk the workspace

Now type

disp(name)
Logical vectors
Logical vectors
Logical vectors

More Related Content

PPTX
Binary search
Raghu nath
 
PPTX
Basic python part 1
National University of Malaysia
 
PDF
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
PDF
201801 CSE240 Lecture 21
Javier Gonzalez-Sanchez
 
ODP
Introduction to FreeMat
Ahmad AlMowaffak
 
PDF
Skip Graphs and its Applications
Ajay Bidyarthy
 
PPTX
Tools for reading papers
Jack Fox
 
PPTX
Algorithm & data structures lec4&5
Abdul Khan
 
Binary search
Raghu nath
 
Basic python part 1
National University of Malaysia
 
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
201801 CSE240 Lecture 21
Javier Gonzalez-Sanchez
 
Introduction to FreeMat
Ahmad AlMowaffak
 
Skip Graphs and its Applications
Ajay Bidyarthy
 
Tools for reading papers
Jack Fox
 
Algorithm & data structures lec4&5
Abdul Khan
 

What's hot (20)

PPTX
Divide and conquer 1
Kumar
 
DOCX
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
PDF
Functions lect
AdnanBukhari13
 
PPTX
Data structures and algorithms
Hoang Nguyen
 
PDF
Lecture4
Mohamed Awni
 
PPTX
Counting sort
zahraa F.Muhsen
 
PPT
L10 sorting-searching
mondalakash2012
 
PPT
Counting Sort Lowerbound
despicable me
 
PDF
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
PPTX
Counting sort
arjunnaik19
 
PPT
Algorithms with-java-advanced-1.0
BG Java EE Course
 
PPTX
Python decision making_loops_control statements part9
Vishal Dutt
 
PPTX
Arrays.pptx
Shweta Bhatia
 
PPT
Matlab on basic mathematics
monauweralam1
 
PPTX
MATLAB - Arrays and Matrices
Shameer Ahmed Koya
 
PPTX
Insertion sort algorithm power point presentation
University of Science and Technology Chitttagong
 
PPT
Big oh Representation Used in Time complexities
LAKSHMITHARUN PONNAM
 
PDF
Sorting Algorithms
Mohammed Hussein
 
PPT
Sorting & Linked Lists
J.T.A.JONES
 
PPTX
Big o notation
hamza mushtaq
 
Divide and conquer 1
Kumar
 
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
Functions lect
AdnanBukhari13
 
Data structures and algorithms
Hoang Nguyen
 
Lecture4
Mohamed Awni
 
Counting sort
zahraa F.Muhsen
 
L10 sorting-searching
mondalakash2012
 
Counting Sort Lowerbound
despicable me
 
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
Counting sort
arjunnaik19
 
Algorithms with-java-advanced-1.0
BG Java EE Course
 
Python decision making_loops_control statements part9
Vishal Dutt
 
Arrays.pptx
Shweta Bhatia
 
Matlab on basic mathematics
monauweralam1
 
MATLAB - Arrays and Matrices
Shameer Ahmed Koya
 
Insertion sort algorithm power point presentation
University of Science and Technology Chitttagong
 
Big oh Representation Used in Time complexities
LAKSHMITHARUN PONNAM
 
Sorting Algorithms
Mohammed Hussein
 
Sorting & Linked Lists
J.T.A.JONES
 
Big o notation
hamza mushtaq
 
Ad

Viewers also liked (20)

PPTX
Michaelpritchard
michaelpritchard
 
PPTX
Matlab
Ketan Paithankar
 
PDF
Tech tut
Ketan Paithankar
 
ODP
Improving your driveway, path or patio.
WrexhamConcreteDesign
 
PPTX
Michaelpritchard
michaelpritchard
 
PPT
Matlab
Ketan Paithankar
 
PPS
Fb Nnew Pps
Dear CD
 
PPT
Matlab graphics
Ketan Paithankar
 
PPT
SIB Green IT Policy
swiss IT bridge
 
PDF
BarCamp in Saigon
swiss IT bridge
 
PDF
Introduction into GIT
swiss IT bridge
 
PPT
An approach to implement model classes in zend
swiss IT bridge
 
PDF
Los espacios en la BECREA. junta de andalucía.
Biblioteca Escolar Juan Leiva
 
PDF
Servicios tradicionales en la BECREA
Biblioteca Escolar Juan Leiva
 
PPT
How to apply Agile in Marketing
swiss IT bridge
 
PDF
GUÍA DE BIBLIOTECAS ESCOLARES. 6. Extensión cultural. Director: José García G...
Biblioteca Escolar Juan Leiva
 
PPT
Client Satisfaction as engine of the continuous improvement
swiss IT bridge
 
Michaelpritchard
michaelpritchard
 
Improving your driveway, path or patio.
WrexhamConcreteDesign
 
Michaelpritchard
michaelpritchard
 
Fb Nnew Pps
Dear CD
 
Matlab graphics
Ketan Paithankar
 
SIB Green IT Policy
swiss IT bridge
 
BarCamp in Saigon
swiss IT bridge
 
Introduction into GIT
swiss IT bridge
 
An approach to implement model classes in zend
swiss IT bridge
 
Los espacios en la BECREA. junta de andalucía.
Biblioteca Escolar Juan Leiva
 
Servicios tradicionales en la BECREA
Biblioteca Escolar Juan Leiva
 
How to apply Agile in Marketing
swiss IT bridge
 
GUÍA DE BIBLIOTECAS ESCOLARES. 6. Extensión cultural. Director: José García G...
Biblioteca Escolar Juan Leiva
 
Client Satisfaction as engine of the continuous improvement
swiss IT bridge
 
Ad

Similar to Logical vectors (20)

PPTX
Csci101 lect09 vectorized_code
Elsayed Hemayed
 
PPTX
presentation.pptx
raghav415187
 
PPTX
EET Lecture for matlab khjbxiubnxjnkjnw
dannymatias208
 
PPTX
Matlab ch1 (1)
mohsinggg
 
PPTX
1. Ch_1 SL_1_Intro to Matlab.pptx
MOHAMMAD SAYDUL ALAM
 
PPT
MatlabIntro1234.ppt.....................
RajeshMadarkar
 
PDF
MATLAB Basics-Part1
Elaf A.Saeed
 
PPT
WIDI ediot autis dongok part 2.ediot lu lembot lu
IrlanMalik
 
PPT
WIDI ediot autis dongok part 3.EDIOT LU LEMBOT LY
IrlanMalik
 
PPTX
BEN520 FUNDAMENTALS OF BOENGINEERING II-4 week-lecture 4.pptx
chemeng87
 
PPT
WIDI ediot autis dongok part 1.ediot lu lemot lu setan lu
IrlanMalik
 
PDF
Matlab booklet
Sourabh Bhattacharya
 
PPT
MatlabIntro.ppt
ShwetaPandey248972
 
PPT
MatlabIntro.ppt
Rajmohan Madasamy
 
PPT
MatlabIntro.ppt
konkatisandeepkumar
 
PPT
MatlabIntro.ppt
ssuser772830
 
PPT
Matlab intro
THEMASTERBLASTERSVID
 
DOCX
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
andreecapon
 
PPTX
2. Chap 1.pptx
HassanShah396906
 
Csci101 lect09 vectorized_code
Elsayed Hemayed
 
presentation.pptx
raghav415187
 
EET Lecture for matlab khjbxiubnxjnkjnw
dannymatias208
 
Matlab ch1 (1)
mohsinggg
 
1. Ch_1 SL_1_Intro to Matlab.pptx
MOHAMMAD SAYDUL ALAM
 
MatlabIntro1234.ppt.....................
RajeshMadarkar
 
MATLAB Basics-Part1
Elaf A.Saeed
 
WIDI ediot autis dongok part 2.ediot lu lembot lu
IrlanMalik
 
WIDI ediot autis dongok part 3.EDIOT LU LEMBOT LY
IrlanMalik
 
BEN520 FUNDAMENTALS OF BOENGINEERING II-4 week-lecture 4.pptx
chemeng87
 
WIDI ediot autis dongok part 1.ediot lu lemot lu setan lu
IrlanMalik
 
Matlab booklet
Sourabh Bhattacharya
 
MatlabIntro.ppt
ShwetaPandey248972
 
MatlabIntro.ppt
Rajmohan Madasamy
 
MatlabIntro.ppt
konkatisandeepkumar
 
MatlabIntro.ppt
ssuser772830
 
Matlab intro
THEMASTERBLASTERSVID
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
andreecapon
 
2. Chap 1.pptx
HassanShah396906
 

Recently uploaded (20)

PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
CDH. pptx
AneetaSharma15
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 

Logical vectors

  • 2. • TYPE as it is in Command Line : r=1; Chk result r<=.5 ( Result is 0) and then at last r>=.5 ( Result is 1) Now Enter the Following statement : r = 1:5; r<=3 U get 11100 as statement is true for first 3 elements
  • 3. • Vectors are compared element by element and the resulting vector is called as Logical Vector. It is one of the most power concepts in MATLAB. • For eg try this : a=1:5; b=[0 2 3 5 6]; a==b % no semicolon (Result is : 0 1 1 0 0)
  • 4. • Applications : Discontinuous Graphs : Type these Statements : x=0:pi/20:3*pi; y=sin(x); y=y .* (y>0); plot(x,y)
  • 5. • What was the Funda ??? y>0 returns a logical vector with ones where sin(x) is positive as y>0 means it is checked element by element if it is >0 ; and if it is not then it returns 0. After this we multiply by y to get the graph
  • 6. • Avoid division by 0 As one of the element of x is exact zero.
  • 7. • Use Logical Vector to replace zero with eps. What is eps? • This MATLAB function returns the difference between 1.0 and the next largest number which can be represented in MATLAB, i.e. approximately 2.2e-16.
  • 8. • So you type and get :
  • 10. • Logical Functions : x is a vector : Try these statements : x=1:5 any(x) any(x) : returns scalar 1 in ans if any element of x is nonzero.
  • 11. • Try for the o/p of x = [ 0 0] any(x) all(x) Returns scalar 1 if all elements of vector x r non zero! x=1:5; all(x) Try to get info abt all logic functions
  • 14. • For Basic i/p o/p of string we have : name = input( 'Enter your surname: ', 's' ); Chk the workspace Now type disp(name)