Matlab, Fourth Edition: A Practical Introduction to Programming and Problem Solving
Matlab, Fourth Edition: A Practical Introduction to Programming and Problem Solving
4th Edition
ISBN: 9780128045251
Author: Stormy Attaway Ph.D. Boston University
Publisher: Elsevier Science
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 1, Problem 1.3P
To determine

To find:

The result produced from the given expressions and verify them using MATLAB.

Expert Solution & Answer
Check Mark

Answer to Problem 1.3P

Solution:

The required result is verified.

Explanation of Solution

The given expressions are,

3==5+2

'b'<'a'+1

10>5+2

(10>5)+2

'c'=='d'-1&&2<4

'c'=='d'-1||2>4

xor('c'=='d'-1, 2>4)

xor('c'=='d'-1, 2<4)

10>5>2

There are only two possibilities that can be concluded from the expression. If the expression is true, then it will have the logical value 1. If the expression is false, then it will have the logical value 0. The given expression “3==5+2” is false. Hence, the output will be 0.

Consider the value of a is 0 and the value of b is 1. The output will be,

b<a+11<0+1

The obtained output is false. Hence, it will have the logical value 0.

The given expression “10>5+2” is false. Hence, the output will be 1.

In the expression “(10>5)+2”, first “(10>5)” will be evaluated. This expression is true. Hence, it will have the logical value 1. Add “2” to this logical value. The final output is 3.

Consider the value of c is 0 and the value of d is 1 in the expression “'c'=='d'-1&&2<4”. The expression becomes,

c==d1&&2<40==11&&2<4

In this expression, the order of preference is “,<,==,&&”. Hence,

0==(11)&&2<40==0&&(2<4)     (0==0)&&1     1&&1     1

Consider the value of c is 0 and the value of d is 1 in the expression “'c'=='d'-1||2>4”. The expression becomes,

c==d1||2>40==11||2>4

In this expression, the order of preference is “,<,==,||”. Hence,

                  0==(11)||2>4                  0==0||(2>4)(0==0)||0                     1||0                        1

Consider the value of c is 0 and the value of d is 1 in the expression “xor('c'=='d'-1, 2>4)”. The expression becomes,

xor(c==d1,2>4)xor(0==11,2>4)

In this expression, the order of preference is “,<,==,xor”. Hence,

xor(0==(11),2>4)xor(0==0,(2>4))xor((0==0),0)xor(1,0)1

Consider the value of c is 0 and the value of d is 1 in the expression “xor('c'=='d'-1&&2<4)”. The expression becomes,

xor(c==d1,2<4)xor(0==11,2<4)

In this expression, the order of preference is “,<,==,xor”. Hence,

xor(0==(11),2<4)xor(0==0,(2<4))xor((0==0),1)xor(1,1)0

In the expression “10>5>2”, first “(10>5)” will be evaluated. This expression is true. Hence, it will have the logical value 1. Now “(1>2)” is false. Hence, it will have the logical value 0.

MATLAB Code:

3==5+2

'b'<'a'+1

10>5+2

(10>5)+2

'c'=='d'-1&&2<4

'c'=='d'-1||2>4

xor('c'=='d'-1, 2>4)

xor('c'=='d'-1, 2<4)

10>5>2

Save the MATLAB script with name, chapter1_54793_1_3P.m in the current folder. Execute the script by typing the script name at the command window to generate output.

Result:

Matlab, Fourth Edition: A Practical Introduction to Programming and Problem Solving, Chapter 1, Problem 1.3P , additional homework tip  1

Matlab, Fourth Edition: A Practical Introduction to Programming and Problem Solving, Chapter 1, Problem 1.3P , additional homework tip  2

Therefore, the required variable is created.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Knowledge Booster
Background pattern image
Statistics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, statistics and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Holt Mcdougal Larson Pre-algebra: Student Edition...
Algebra
ISBN:9780547587776
Author:HOLT MCDOUGAL
Publisher:HOLT MCDOUGAL
Text book image
Intermediate Algebra
Algebra
ISBN:9781285195728
Author:Jerome E. Kaufmann, Karen L. Schwitters
Publisher:Cengage Learning
Text book image
Algebra for College Students
Algebra
ISBN:9781285195780
Author:Jerome E. Kaufmann, Karen L. Schwitters
Publisher:Cengage Learning
Text book image
Glencoe Algebra 1, Student Edition, 9780079039897...
Algebra
ISBN:9780079039897
Author:Carter
Publisher:McGraw Hill
Text book image
Intermediate Algebra
Algebra
ISBN:9780998625720
Author:Lynn Marecek
Publisher:OpenStax College
Text book image
College Algebra (MindTap Course List)
Algebra
ISBN:9781305652231
Author:R. David Gustafson, Jeff Hughes
Publisher:Cengage Learning
What is a Linear Equation in One Variable?; Author: Don't Memorise;https://www.youtube.com/watch?v=lDOYdBgtnjY;License: Standard YouTube License, CC-BY
Linear Equation | Solving Linear Equations | What is Linear Equation in one variable ?; Author: Najam Academy;https://www.youtube.com/watch?v=tHm3X_Ta_iE;License: Standard YouTube License, CC-BY