<< Chapter < Page Chapter >> Page >

Then

E F [ 1 1 0 0 1 1 1 1 ] , E F [ 0 1 0 0 0 0 0 1 ] , and E c [ 1 0 1 1 0 1 0 0 ]

MATLAB logical operations

MATLAB logical operations on zero-one matrices provide a convenient way of handling Boolean combinations of minterm vectors represented as matrices. For two zero-one matrices E , F of the same size

  • E | F is the matrix obtained by taking the maximum element in each place.
  • E & F is the matrix obtained by taking the minimum element in each place.
  • E C is the matrix obtained by interchanging one and zero in each place in E .

Thus, if E , F are minterm vectors for sets by the same name, then E | F is the minterm vector for E F , E & F is the minterm vector for E F , and E = 1 - E is the minterm vector for E c .

This suggests a general approach to determining minterm vectors for Boolean combinations.

  1. Start with minterm vectors for the generating sets.
  2. Use MATLAB logical operations to obtain the minterm vector for any Boolean combination.

Suppose, for example, the class of generating sets is { A , B , C } . Then the minterm vectors for A , B , and C , respectively, are

A = [ 0 0 0 0 1 1 1 1 ] B = [ 0 0 1 1 0 0 1 1 ] C = [ 0 1 0 1 0 1 0 1 ]

If E = A B C c , then the logical combination E = ( A & B ) | C of the matrices yields E = [ 1 0 1 0 1 0 1 1 ] .

MATLAB implementation

A key step in the procedure just outlined is to obtain the minterm vectors for the generating elements { A , B , C } . We have an m-function to provide such fundamental vectors. For example to produce the second minterm vector for the family(i.e., the minterm vector for B ), the basic zero-one pattern 0 0 1 1 is replicated twice to give

0 0 1 1 0 0 1 1

The function minterm(n,k) generates the k th minterm vector for a class of n generating sets.

Minterms for the class { A , B , C } .

>>A = minterm(3,1) A = 0 0 0 0 1 1 1 1>>B = minterm(3,2) B = 0 0 1 1 0 0 1 1>>C = minterm(3,3) C = 0 1 0 1 0 1 0 1
Got questions? Get instant answers now!

Minterm patterns for the boolean combinations

F = A B B c C G = A A c C

F = (A&B)|(~B&C) F = 0 1 0 0 0 1 1 1>>G = A|(~A&C) G = 0 1 0 1 1 1 1 1>>JF = find(F)-1 % Use of find to determine index set for F JF = 1 5 6 7 % Shows F = M(1, 5, 6, 7)
Got questions? Get instant answers now!

These basic minterm patterns are useful not only for Boolean combinations of events but also for many aspects of the analysis of those random variables which take on onlya finite number of values.

Zero-one arrays in MATLAB

The treatment above hides the fact that a rectangular array of zeros and ones can have two quite different meanings and functions in MATLAB.

  1. A numerical matrix (or vector) subject to the usual operations on matrices..
  2. A logical array whose elements are combined by a. Logical operators to give new logical arrays;b. Array operations (element by element) to give numerical matrices; c. Array operations with numerical matrices to give numerical results.

Some simple examples will illustrate the principal properties.

>>>A = minterm(3,1);>>B = minterm(3,2);>>C = minterm(3,3);>>F = (A&B)|(~B&C) F = 0 1 0 0 0 1 1 1>>G = A|(~A&C) G = 0 1 0 1 1 1 1 1>>islogical(A) % Test for logical array ans = 0>>islogical(F) ans = 1>>m = max(A,B) % A matrix operation m = 0 0 1 1 1 1 1 1>>islogical(m) ans = 0>>m1 = A|B % A logical operation m1 = 0 0 1 1 1 1 1 1>>islogical(m1) ans = 1>>a = logical(A) % Converts 0-1 matrix into logical array a = 0 0 0 0 1 1 1 1>>b = logical(B)>>m2 = a|b m2 = 0 0 1 1 1 1 1 1>>p = dot(A,B) % Equivalently, p = A*B' p = 2>>p1 = total(A.*b)p1 = 2>>p3 = total(A.*B) p3 = 2>>p4 = a*b' % Cannot use matrix operations on logical arrays ??? Error using ==>mtimes % MATLAB error signal Logical inputs must be scalar.

Questions & Answers

if three forces F1.f2 .f3 act at a point on a Cartesian plane in the daigram .....so if the question says write down the x and y components ..... I really don't understand
Syamthanda Reply
hey , can you please explain oxidation reaction & redox ?
Boitumelo Reply
hey , can you please explain oxidation reaction and redox ?
Boitumelo
for grade 12 or grade 11?
Sibulele
the value of V1 and V2
Tumelo Reply
advantages of electrons in a circuit
Rethabile Reply
we're do you find electromagnetism past papers
Ntombifuthi
what a normal force
Tholulwazi Reply
it is the force or component of the force that the surface exert on an object incontact with it and which acts perpendicular to the surface
Sihle
what is physics?
Petrus Reply
what is the half reaction of Potassium and chlorine
Anna Reply
how to calculate coefficient of static friction
Lisa Reply
how to calculate static friction
Lisa
How to calculate a current
Tumelo
how to calculate the magnitude of horizontal component of the applied force
Mogano
How to calculate force
Monambi
a structure of a thermocouple used to measure inner temperature
Anna Reply
a fixed gas of a mass is held at standard pressure temperature of 15 degrees Celsius .Calculate the temperature of the gas in Celsius if the pressure is changed to 2×10 to the power 4
Amahle Reply
How is energy being used in bonding?
Raymond Reply
what is acceleration
Syamthanda Reply
a rate of change in velocity of an object whith respect to time
Khuthadzo
how can we find the moment of torque of a circular object
Kidist
Acceleration is a rate of change in velocity.
Justice
t =r×f
Khuthadzo
how to calculate tension by substitution
Precious Reply
hi
Shongi
hi
Leago
use fnet method. how many obects are being calculated ?
Khuthadzo
khuthadzo hii
Hulisani
how to calculate acceleration and tension force
Lungile Reply
you use Fnet equals ma , newtoms second law formula
Masego
please help me with vectors in two dimensions
Mulaudzi Reply
how to calculate normal force
Mulaudzi
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Applied probability. OpenStax CNX. Aug 31, 2009 Download for free at http://cnx.org/content/col10708/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Applied probability' conversation and receive update notifications?

Ask