Octave Arrays And Vectors

Description

A vector is an $n$-tuple of numbers. In Octave, we enclose vectors in square brackets

Sage Cell

Code

a = [1 4 5]

Options

Option

We can use a(3) to access the third element in the vector a.

Code

a = [1 2 3 4 5 6 7 8 9 10]
a(3)

Option

We can separate the entries in a vector with commas instead of spaces.

Code

a = [1, 4, 5]

Option

If we separate the entries in a vector with semicolons, we obtain a column vector.

Code

a = [1; 4; 5]

Option

We can also build longer vectors from shorter one.

Code

a = [1 4 5]
b = [a 6 7]

Option

The colon notation can be used as a shortcut to create vectors.

Code

a = 2:10
b = 2:0.6:10

Tags

Primary Tags:

Secondary Tags:

Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.

Attribute

Permalink:

Author:T. W. Judson

Date: 05 Dec 2018 18:30

Submitted by: Tom Judson

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License