Source:http://www.mathworks.com/access/helpdesk/help/toolbox/finance/f2-1001993.html
Many financial analysis operations involve sets of numbers; Matrices, matrix functions, and matrix algebra are the most efficient ways to analyze sets of numbers and their relationships. Spreadsheets focus on individual cells and the relationships between cells. A matrix-oriented tool like MATLAB software manipulates sets of numbers more quickly, easily, and naturally.
For example, here is a 2-by-3 matrix of two bonds (the rows) with different par values, coupon rates, and coupon payment frequencies per year (the columns) entered using MATLAB notation:
Bonds =
Many financial analysis operations involve sets of numbers; Matrices, matrix functions, and matrix algebra are the most efficient ways to analyze sets of numbers and their relationships. Spreadsheets focus on individual cells and the relationships between cells. A matrix-oriented tool like MATLAB software manipulates sets of numbers more quickly, easily, and naturally.
For example, here is a 2-by-3 matrix of two bonds (the rows) with different par values, coupon rates, and coupon payment frequencies per year (the columns) entered using MATLAB notation:
Bonds =
[1000 0.06 2
500 0.055 4]
Vector. A matrix with only one row or column. The description is always "row-by-column." For example, here is a 1-by-4 vector of cash flows in MATLAB notation:
Cash = [1500 4470 5280 -1299]
500 0.055 4]
Vector. A matrix with only one row or column. The description is always "row-by-column." For example, here is a 1-by-4 vector of cash flows in MATLAB notation:
Cash = [1500 4470 5280 -1299]
Referencing Matrix Elements
To reference specific matrix elements, use (row, column) notation. For example:
Bonds(1,2)
ans =
0.06
Cash(3)
ans =
5280.00
We can also enlarge matrices using small matrices or vectors . For example,
AddBond = [1000 0.065 2];
Bonds = [Bonds; AddBond]
addsanother row to the matrix and creates
Bonds =
1000 0.06 2
500 0.055 4
1000 0.065 2
Transposing Matrices
In MATLAB, the apostrophe or prime character (') transposes a matrix: columns become rows, rows become columns. For example,
Cash = [1500 4470 5280 -1299]'
produces
Cash =
1500
4470
5280
-1299
ans =
5280.00
We can also enlarge matrices using small matrices or vectors . For example,
AddBond = [1000 0.065 2];
Bonds = [Bonds; AddBond]
addsanother row to the matrix and creates
Bonds =
1000 0.06 2
500 0.055 4
1000 0.065 2
Transposing Matrices
In MATLAB, the apostrophe or prime character (') transposes a matrix: columns become rows, rows become columns. For example,
Cash = [1500 4470 5280 -1299]'
produces
Cash =
1500
4470
5280
-1299
No comments:
Post a Comment