GAUSS Quick Reference

Basic functions

new; remove all variables from your GAUSS workspace.
cls; clear program output from the GAUSS Program Input/Output Window.
f = filesa(file_pattern); returns a string array containing all files that match 'file_pattern'.
chdir new_directory; sets your GAUSS current working directory to 'new_directory'.
cwd = cdir(0); returns your GAUSS current working directory.

Matrix creation

x = { 1 2, 3 4 }; create a 2x2 matrix.
x = seqa(start, step, count); creates a sequence of 'count' numbers starting at 'start' and increasing by 'step'.
x = seqm(start, mult, count); creates a sequence of 'count' numbers starting at 'start' and increasing by a multiple of 'mult'.
x = zeros(m, n); creates an 'm' by 'n' matrix with all elements set to 0.
x = ones(m, n); creates an 'm' by 'n' matrix with all elements set to 1.
x = rndn(m, n); creates an 'm' by 'n' matrix of random normal numbers.
x = rndu(m, n); creates an 'm' by 'n' matrix of uniformly distributed random numbers.

Matrix manipulation

a = x[row,col]; extract the element of 'x' located at 'row:col'.
a = x[.,col]; extract all rows of the specified column(s) of 'x'.
a = x[row,.]; extract all columns of the specified row(s) of 'x'.
a = x[r_start:r_end,.]; extract all columns from the row range 'row_start' to 'row_end'.
a = x[a b c, col]; extract the elements from rows 'a', 'b', and 'c' in column 'col'.
a = x ~ y; horizontally concatenate 'x' and 'y'.
a = x | y; vertically concatenate 'x' and 'y'.
a = reshape(x, m, n); reshape 'x' to be an 'm' by 'n' matrix.
a = delrows(x, idx); returns all rows of 'x' except those listed in 'idx'.
a = delif(x, logical); returns all rows of 'x' except the rows that match a logical expression.
a = selif(x, logical); returns all rows of 'x' that match a logical expression.

Operators

Element-by-element (ExE) operators  
z = x .* y; Element-by-element multiply.
z = x ./ y; Element-by-element divide.
z = x .^ y; Element-by-element exponentiation.
z = x + y; Element-by-element addition.
z = x - y; Element-by-element subtraction.
Matrix operators  
z = x * y; Matrix multiply.
b = y / x; Solve a system of linear equations.
z = x .*. y; Kronecker product.
z = x'; Matrix transpose.
Scalar logical operators  
z = x and y; Scalar logical AND.
z = x or y; Scalar logical OR.
Element-by-element (ExE) logical operators  
z = x .and y; Element-by-element logical AND.
z = x .or y; Element-by-element logical OR.
z = x .> y; Element-by-element greater than.
z = x .< y; Element-by-element less than.
z = x .== y; Element-by-element equality test.
z = x .!= y; Element-by-element inequality test.
Matrix logical operators  
z = x > y; is every element in 'x' greater than its corresponding element in 'y'.
z = x < y; is every element in 'x' less than its corresponding element in 'y'
z = x == y; does every element of 'x' equal its corresponding element in 'y'.
z = x != y; is every element in 'x' different than its corresponding element in 'y'.

String creation

s = "this is a string"; create string containing 'this is a string'.
s = "this is " $+ "a string"; combine strings.
string sa = { "cpi" "ppi", "m1" "m2" }; create 2x2 string array.
s = ntos(n); convert numeric 'n' to a string.

String array manipulation

s = sa[r, c]; extract the r, c element of 'sa'.
s = sa[., c]; extract all rows of the, 'c'th column of 'sa'.
s = sa[r, .]; extract 'r'th row of 'sa'.
sa = "producer" $~ "prices"; horizontal concatenation of strings.
sa = "County" $| "State"; vertical concatenation of strings.
idx = indsav(what, where); returns the location of the strings from 'what' in the string array 'where'.
su = intrsectsa(s_1, s_2); returns the intersection of the string arrays 's_1' and 's_2'.

Loading and saving data

x = spreadSheetReadM(file, range, sheet); reads the specified data into a GAUSS matrix.
sa = spreadSheetReadSA(file, range, sheet); reads the specified data into a GAUSS string array.
ret = spreadSheetWrite(x, file, range, sheet); writes the data from the GAUSS matrix or string array 'x' into the specified Excel® file.
x = loadd(dataset); loads the data from a GAUSS dataset into a GAUSS matrix.
ret = saved(x, dataset, v_names); saves the data from 'x' to a GAUSS dataset.
x = csvReadM(file, row_range, col_range); reads data from a text delimited file, such as CSV, to a GAUSS matrix.
x = csvReadSA(file, row_range, col_range); reads data from a text delimited file, such as CSV, to a GAUSS string array.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.