Appendix E. Solutions to Selected Exercises

Chapter 1

1.1.

     a = 3;
     b = 5;
     sum = a + b;
     difference = a - b;
     product = a * b;
     quotient = a / b;

Chapter 2

2.1.

  1. Comma should be replaced by decimal point

  2. Asterisk should be omitted

  3. Exponent must be integer

  4. Comma should be replaced by decimal point

2.2.

  1. Decimal point not allowed

  2. First character must be letter

  3. Quotes not allowed

  4. Blanks not allowed

  5. Allowed but not recommended

  6. Asterisk not allowed

  7. Allowed but not recommended

2.3.

  1. p + w/u

  2. p + w/(u + v)

  3. (p + w/(u+v))/(p + w/(u-v))

  4. sqrt(x)

  5. y^(y+z)

  6. x^(y^z)

  7. (x^y)^z

  8. x - x^3/(3*2) + x^5/(5*4*3*2)

2.4.

  1. i = i + 1

  2. i = i^3 + j

  3.    if e > f
         g = e
       else
         g = f
       end
  4.    if d > 0
         x = -b
       end
  5. x = (a + b)/(c * d)

2.5.

  1. Expression not allowed on left-hand side

  2. Left-hand side must be valid variable name

  3. Left-hand ...

Get Essential MATLAB for Engineers and Scientists Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.