> Financial Mathematics
>> MATLAB Programming
>>> Simplification in MATLAB

Simplification in MATLAB

Learn the simplification methods in MATLAB. Matlab obeys the DMAS (Division, Multiplication, Addition and Subtraction) Rule. That is it first divides, then multiply, then adds and then subtract values.

MATLAB Simplification


Q. Solve in MATLAB: 1 + 2 * 3 = ?


1 + 2 * 3 (press Enter)
The Matlab shows: ans = 7
Matlab first multiply 2 and 3, and then add 1.


Q. Solve in MATLAB: -4 + 8 / 2 * 3 = ?


-4 + 8 / 2 * 3 (press Enter)
The Matlab shows: ans = 8
Matlab first divided 8 by 2. Then multiply the answer with 3, and then subtract 4.


Q. Solve in MATLAB:


8/(2+2) (press Enter)
The Matlab shows: ans = 2
8/2+2 (press Enter)
The Matlab shows: ans = 6

So, brackets are important. In the second program tha Matlab first divided 8 by 2 and then add 2. So the answer is 6. Which is wrong!




Q. Solve in MATLAB:


8/(2+2)^3 (press Enter)
The Matlab shows: ans = 0.125

Scientific Notation in MATLAB



Q. Find the values of following in MATLAB


(1)
>> 1.7*10^2 (press Enter)
ans =
     170

(2)
>> 1.9*10^3 (press Enter)
ans =
     1900

(3)
>> 2.5*10^-5 (press Enter)
ans =
     2.5000e-05

(4)
>> 2.8*10^-6 (press Enter)
ans =
     2.8000e-06



Q. Find the values of


>> 1.2*10^3+1.3*10^4 (press Enter)
ans =
     14200

Next: MATLAB Functions