# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

## Analyze Sets of Numbers Using Matrix Functions

### Introduction

Many financial analysis procedures involve sets of numbers; for example, a portfolio of securities at various prices and yields. 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. While you can think of a set of spreadsheet cells (a range of rows and columns) as a matrix, a matrix-oriented tool like MATLAB® software manipulates sets of numbers more quickly, easily, and naturally. For more information, see Matrix Algebra Refresher.

### Key Definitions

#### Matrix

A rectangular array of numeric or algebraic quantities subject to mathematical operations; the regular formation of elements into rows and columns. Described as a “m-by-n” matrix, with m the number of rows and n the number of columns. The description is always “row-by-column.” 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. Described as a “`1`-by-n” or “m-by-`1`” matrix. 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] ```

#### Scalar

A `1`-by-`1` matrix; that is, a single number.

### 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 ```

You can enlarge matrices using small matrices or vectors as elements. For example,

```AddBond = [1000 0.065 2]; Bonds = [Bonds; AddBond] ```

adds another row to the matrix and creates

```Bonds = 1000 0.06 2 500 0.055 4 1000 0.065 2 ```

Likewise,

```Prices = [987.50 475.00 995.00] Bonds = [Prices, Bonds] ```

adds another column and creates

```Bonds = 987.50 1000 0.06 2 475.00 500 0.055 4 995.00 1000 0.065 2 ```

Finally, the colon (`:`) is important in generating and referencing matrix elements. For example, to reference the par value, coupon rate, and coupon frequency of the second bond:

`BondItems = Bonds(2, 2:4)`
```BondItems = 500.00 0.055 4 ```

### Transposing Matrices

Sometimes matrices are in the wrong configuration for an operation. 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 ```

## Related Topics

Was this topic helpful?

#### Financial Risk Management: Improving Model Governance with MATLAB

Download the white paper
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}