Vectors

Vectors in AUXLAB behave much like vectors in MATLAB-style numerical environments, but the language also keeps the syntax consistent with audio-oriented operations.

Indexing

AUX> x(20:25)
x(20:25) = 81 80 79 78 77 76
AUX> x([2 5 10:13])
x([2 5 10:13]) = 99 96 91 90 89 88
AUX> x(end-1:end) // here end means 100, because the length of x is 100
x(end-1:end) = 2 1

Vector Arithmetic

AUX> 10 + [1 2 3]
ans = 11 12 13
AUX> [1 2 3] + [1 2 3 4 5]
ans = 2 4 6 4 5

Assignment And Replacement

AUX> x(9)=0
x = 100 99 98 97 96 95 94 93 0 91 ... (length = 100)
AUX> x(1:3)=[29 8 -1]
x = 29 8 -1 97 96 95 94 93 0 91 ... (length = 100)
AUX> x(1:4)=[55 56]
x = 55 56 96 95 94 93 0 91 90 89 ... (length = 98)
AUX> x([1 3 4])=[55 56]
(ERROR MESSAGE!!!)
AUX> x([1 3 4])=[-1 -2 -3]
x = -1 -2 96 -3 94 93 0 91 90 89 ... (length = 98)
AUX> x(1:3)=0
x = 0 0 0 -3 94 93 0 91 90 89 ... (length = 98)
AUX> x([1:3 8 10])=-1
x = -1 -1 -1 -3 94 93 0 -1 90 -1 ... (length = 98)

Compound Assignment

When a compound operator is used (+=, -=, *=, /=, or %=), the affected left-hand-side elements are updated according to the indexing selection.

AUX> x([1:3 8 10])+=1
x = 0 0 0 -3 94 93 0 0 90 0 ... (length = 98)

Conditional Indexing

AUX> x=(0:100).sqrt
x = 0 1 1.414 1.732 2 2.236 2.449 2.645 2.828 3 ... (length = 100)
AUX> x(x>3 && x<4)
ans = 3.162 3.317 3.464 3.606 3.742 3.873
AUX> x=1:100
x = 1 2 3 4 5 6 7 8 9 10 ... (length = 100)
AUX> x(x%2==0)=99
x = 1 99 3 99 5 99 7 99 9 99 ... (length = 100)
AUX> x=1:100
x = 1 2 3 4 5 6 7 8 9 10 ... (length = 100)
AUX> x(x%2==0)*=10
x = 1 20 3 40 5 60 7 80 9 100 ... (length = 100)

Current source basis: