Start learning today, and be successful in your academic & professional career. Start Today!

Loading video...

Enter your Sign on user name and password.

Start learning today, and be successful in your academic & professional career. Start Today!

Loading video...

## Discussion

## Study Guides

## Practice Questions

## Download Lecture Slides

## Table of Contents

## Related Books

- We can use rational operators to construct logical values and vectors, moreover we have the following logical operands as well:
- Operator ~ Meaning NOT
- Operator & Meaning AND
- Operator | Meaning OR
- A more comprehensive operator precedence table is as follows, note that you can use rational operators as logical operators as well:
- Precedence 1 Operators ()
- Precedence 2 Operators ^ .^ ‘ .’ (pure transpose)
- Precedence 3 Operators + (unary plus) – (unary minus) ~ (NOT)
- Precedence 4 Operators / \ .* ./ .\
- Precedence 5 Operators + (addition) – (subtraction)
- Precedence 6 Operators :
- Precedence 7 Operators < >= <= == ~=
- Precedence 8 Operators & (AND)
- Precedence 9 Operators | (OR)

Without using MATLAB, guess what is the value of x in each case:

X = 3 > 2

X = 2 > 3

X = 0 < 0.5 < 1

X = 3 > 2

X = 2 > 3

X = 0 < 0.5 < 1

X = 3 > 2

X = 1

X = 2 > 3

X = 0

X = 0 < 0.5 < 1

X = 0

X = 1

X = 2 > 3

X = 0

X = 0 < 0.5 < 1

X = 0

A mortgage bond (loan) of amount L is obtained to buy a house. The interest rate r is 15 percent (0.15) p.a. The fixed monthly payment P which will pay off the bond exactly over N years is given by the formula:

P = [(rL(1+r/12)^{12N})/(12[(1+r/12)^{12N}−1])]

(a) Write a program to compute and print P if N = 20 years, and the bond is for $50 000. You should get $658.39

(b) It's interesting to see how the payment P changes with the period N over which you pay the loan. Run the program for different values of N (use input)

See if you can find a value of N for which the payment is less than $625

(c) Now go back to having N fixed at 20 years, and examine the effect of different interest rates. You should see that raising the interest rate by 1 percent (0.01) increases the monthly payment by about $37

P = [(rL(1+r/12)

(a) Write a program to compute and print P if N = 20 years, and the bond is for $50 000. You should get $658.39

(b) It's interesting to see how the payment P changes with the period N over which you pay the loan. Run the program for different values of N (use input)

See if you can find a value of N for which the payment is less than $625

(c) Now go back to having N fixed at 20 years, and examine the effect of different interest rates. You should see that raising the interest rate by 1 percent (0.01) increases the monthly payment by about $37

r = 0.15;

N = 20;

L = 50000;

P = (r*L*((1+r/12)^{∧} (12*N)))/(12*((1+r/12) ^{∧} (12*N)-1))

N = input('please enter number of years: ');

P = (r*L*((1+r/12)^{∧} (12*N)))/(12*((1+r/12) ^{∧} (12*N)-1))

N = 20;

L = 50000;

P = (r*L*((1+r/12)

N = input('please enter number of years: ');

P = (r*L*((1+r/12)

It's useful to be able to work out how the period of a bond repayment changes if you increase or decrease your monthly payment P. The formula for the number of years N to repay the loan is given by

N=[(ln([P/(P−rL/12)]))/(12ln(1+r/12))]

(a) Write a new program to compute this formula. Use the built-in function log for the natural logarithm ln. How long will it take to pay off the loan of $50000 at $800 a month if the interest remains at 15 percent?

(b) Use your program to find out by trial-and-error the smallest monthly payment that can be made to pay the loan off this side of eternity. Hint: Recall that it is not possible to find the logarithm of a negative number, so P must not be less than rL/12.

N=[(ln([P/(P−rL/12)]))/(12ln(1+r/12))]

(a) Write a new program to compute this formula. Use the built-in function log for the natural logarithm ln. How long will it take to pay off the loan of $50000 at $800 a month if the interest remains at 15 percent?

(b) Use your program to find out by trial-and-error the smallest monthly payment that can be made to pay the loan off this side of eternity. Hint: Recall that it is not possible to find the logarithm of a negative number, so P must not be less than rL/12.

(a)10.2 years — nearly twice as fast as when paying $658 a month!

(b) r = 0.15;

N = 20;

L = 50000;

P = (r*L*((1+r/12)^{∧} (12*N)))/(12*((1+r/12) ^{∧} (12*N)-1))

r = r+ 0.01;

P2 = (r*L*((1+r/12)^{∧} (12*N)))/(12*((1+r/12) ^{∧} (12*N)-1))

change = P2 - P

r = 0.15;

L = 50000;

P = 800;

N = log(P/(P−r*L/12))/(12*log(1+r/12))

P = r*L/12 + eps;

N = log(P/(P−r*L/12))/(12*log(1+r/12));

while N > 30

P = P + 0.01;

N = log(P/(P−r*L/12))/(12*log(1+r/12));

end

(b) r = 0.15;

N = 20;

L = 50000;

P = (r*L*((1+r/12)

r = r+ 0.01;

P2 = (r*L*((1+r/12)

change = P2 - P

r = 0.15;

L = 50000;

P = 800;

N = log(P/(P−r*L/12))/(12*log(1+r/12))

P = r*L/12 + eps;

N = log(P/(P−r*L/12))/(12*log(1+r/12));

while N > 30

P = P + 0.01;

N = log(P/(P−r*L/12))/(12*log(1+r/12));

end

*These practice questions are only helpful when you work on them offline on a piece of paper and then use the solution steps function to check your answer.

Answer

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

- Intro 0:00
- Logical Operators and Vectors 0:09
- Logical Functions 1:09
- Any
- Exist
- Find(x) 2:20
- Defining a New Vector
- Logical Vectors Instead of Elseif Ladders 4:35
- Example: Tax 4:45
- If ti
- Elseif ti
- Executing in MATLAB
- Example: Using Logical Vector

I. Introduction | ||
---|---|---|

MATLAB Essentials, Part 1 | 8:36 | |

MATLAB Essentials, Part 2 | 7:39 | |

II. MATLAB Fundamentals | ||

Introduction to Programs | 6:42 | |

Arrays & Matrices | 7:06 | |

Operator, Expression & Statements | 13:26 | |

Repeating With For | 14:21 | |

Decisions, Part 1 | 14:35 | |

Decisions, Part 2 | 8:53 | |

Last Notes on MATLAB Introduction | 9:47 | |

III. Logical Vectors | ||

Logical Vectors, Part 1 | 11:23 | |

Logical Vectors, Part 2 | 11:40 | |

IV. Program Design | ||

Program Design & Algorithm Development | 19:36 | |

V. Graphics | ||

Graphics, Part 1 | 9:14 | |

Graphics, Part 2 | 17:20 | |

Graphics, Part 3 | 18:37 | |

VI. Loops | ||

Loops | 10:38 | |

While | 17:01 | |

VII. Project | ||

Projectile Problem | 16:33 | |

VIII. Function M-Files | ||

Function M-Files, Part 1 | 12:55 | |

Function M-Files, Part 2 | 14:14 | |

Function M-Files, Part 3 | 11:54 | |

IX. Graphics Continued | ||

More on Graphics | 11:13 | |

Graphical User Interface, Part 1 | 7:25 | |

Graphical User Interface, Part 2 | 9:33 | |

X. Dynamical Systems | ||

Dynamical Systems | 12:45 | |

XI. Simulation | ||

Examples of Simulation | 10:45 | |

XII. Numerical Methods | ||

Numerical Methods | 22:20 | |

XIII. Simulink | ||

Simulink | 9:37 |

0 answers

Post by Neil Tugby on August 31, 2014

In the practice question, the input X = 0 < 0.5 < 1 returns 0, even though all statements are true. If X = 0 < 1<10 is entered however, the result is 1. Can u please explain why this happens?

0 answers

Post by Tony Matth on June 5, 2014

You first wrote disp([ti tax])(@7.48) and then wrote disp([inc' tax']) (@10.45). You didn't use the symbol ' for the first operator, however display results are same. Why is that?