Utilities

applyToNonNan(data, func)[source]

Apply the given function columnwise to all non NaN values in the given data.

USAGE

result = applyToNonNan (data,func)

INPUTS
  • data – Matrix of data (individuals x variables)

  • func – function handle that takes an vector of data and computes single value result.

OUTPUTS

result – A Vector of with dimensions (size(data,2) x 1) where the supplied function was applied to all columns ignoring NaN values.

calcDist(searchString, databaseString)[source]

Calculate a Distance between the searchString and the database string. a perfect match will return a distance of 0. The distance is a modified levenshtein edit distance. leading or trailing elements in the search string have a cost of 0.8 leading or trailing elements in the database String have a cost of 0.1 Uppercase <-> lower case edits have a cost of 0.05 All other edit operations have a cost of 1

USAGE

d = calcDist (searchString,databaseString)

INPUTS
  • searchString – The string that is used as a query

  • databaseString – The string in a database that the search string is compared to.

OUTPUT

d – A Distance between the searchString and the databaseString.

Note

This function is not a metric i.e. calcDist(a,b) ~= calcDist(b,a) !

clearGlobal(globalName)[source]

Safely clear a global variable.

USAGE

clearGlobal (globalName)

INPUTS

globalName – The name of the global variable to clear.

columnVector(vec)[source]

Converts a vector to a column vector

USAGE

vecT = columnVector (vec)

INPUT

vec – a vector

OUTPUT

vecT – a column vector

countUnique(list)[source]

Count unique elements in a vector (cell array or numerical) Also sorts the unique elements in descending order

USAGE

[sortedList, sortedCount] = countUnique (list)

INPUT

list – input vector

OUTPUTS
  • sortedList – list with sorted elements

  • sortedCount – number of elements

dispMatrix(A, mode)[source]

display a matrix A in a tight format

INPUT A m x n matrix mode ‘Z’ integers (default)

‘N’ natural number

duplicates(A)[source]

create a map M between the first instance (row) and other instances (cols) of an equivalent set using [C,IA,IC]=unique(A,’rows’,’stable’);

INPUT A m x n array (compatible with unique.m)

OUTPUT M m x m array where M(i,j) = 1 if the first instance of i has a

duplicate j, and M(i,j) = 0 otherwise.

C unique first instances in the same order that they appear in A IA C = A(IA,:) IC A = C(IC,:)

USAGE A=[‘a’;’a’;’b’;’c’;’d’;’d’;’b’;’b’;’e’];

M =

0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

duplicateBool =

0 1 0 0 0 1 1 1 0

extendIndicesInDimenion(input, dimension, value, sizeIncrease)[source]

Remove the indices in a specified field in the given dimension :USAGE: added = extendIndicesInDimenion (input,dimension,indices)

INPUTS
  • input – The input matrix or array

  • dimension – The dimension in which to add values for the given indices

  • value – The value to append in the given dimension.

  • sizeIncrease – How many entries to add.

OUTPUT

added – The Array/Matrix with the given indices set to the default values.

getDefaultTableRow(tableRow)[source]

get a default table row :USAGE: defaultRow = getDefaultTableRow (tablerow)

INPUT

tableRow – The row for which to define a default row

OUTPUT

defaultRow – A row with default values for different data types

getDefaultValue(value)[source]

get the default value for a given value (NaN for numeric, empty strings for textual, false for logical) :USAGE: defValue = getDefaultValue (value)

INPUT

value – The value to get a default for

OUTPUT

defValue – The default value for the given values type.

getEnvironment()[source]

Get all values of current globals in a struct. :USAGE: environment = getEnvironment()

OUTPUT

environment – a struct with two fields * .globals - contains all global values * .path - contains the current path

getGlobalValue(globalName)[source]

Safely get the Value of a global variable.

USAGE

value = getGlobalValue (globalName)

INPUTS

globalName – The name of the global variable to get the value for

OUTPUT

value – The value of the requested global variable

issueConfirmationWarning(message)[source]

Issues a warning, which and blocks execution until confirmation by the user. :USAGE: issueConfirmationWarning (message)

INPUTS

message – The message to be displayed

isvar(T, varName)[source]

checks if varName is a column of table T

mapAontoB(Akey, Bkey, Ain, Bin, printLevel)[source]

Maps the data from Ain onto Bin by matching keys from Akey onto Bkey If Akey is not unique, it maps the lowest absolute index in Akey to the corresponding Bkey, but gives a warning, unless printLevel=0;

USAGE

[Bout,LIBkey,LOCAkey] = mapAontoB (Akey,Bkey,Ain,Bin)

INPUTS
  • Akey – m x 1 primary key in array or table Ain

  • Bkey – n x 1 primary key in array or table Bin

  • Ain – m x z array or table

OPTIONAL INPUTS
  • Bin – n x y array or table, which is created starting from Bkey if Bin is not provided.

  • Ain.Properties.VariableNames – required if Ain is a table

OUTPUTS
  • Bout – n x y array or table, which is created starting from Bkey if Bin is not provided.

  • LIBkey – n x 1 array of the same size as B containing true where the elements of B are in A and false otherwise. Output from [LIBkey,LOCAkey] = ismember(Bkey,Akey);

  • LOCAkey – n x 1 array containing the lowest absolute index in A for each element in B which is a member of A and 0 if there is no such index.Output from [LIBkey,LOCAkey] = ismember(Bkey,Akey);

EXAMPLE:

NOTE:

Author(s):

removeIndicesInDimenion(input, dimension, indices)[source]

Remove the indices in a specified field in the given dimension :USAGE: removed = removeIndicesInDimenion (input, dimension, indices)

INPUTS
  • input – The input matrix or array

  • dimension – The dimension from which to remove the indices

  • indices – The indices to remove

OUTPUT

removed – The array/matrix with the given indices removed.

removeZeroRowsCols(A)[source]

removes all zero rows and columns from a matrix

restoreEnvironment(environment, restorePath, printLevel)[source]

Reset all global variables to a value stored in the input struct (all variables not present will be deleted. :USAGE: restoreEnvironment (globals)

INPUTS
  • environment – A struct with the following fields: * .globals: a struct with the fields being global variables and the value the respective values. * .path: the path to restore (it will override the current path)

  • restorePath – Also restore the path (default: true)

  • printLevel – Set the verbosity of this method: * 0: No outputs (Default) * 1: Info what each value is set to

setGlobal(globalName, globalValue)[source]

Safely set a global Variable to a specific value.

USAGE

setGlobal (globalName,globalValue)

INPUTS
  • globalName – A string representing the name of the global variable

  • globalValue – The value to set the global variable to

showprogress(x, whichbar)[source]

showprogress shows waitbars

INPUTS
  • x – percentage in integer (e.g.: 1 = 1%, 40 = 40%, etc.)

  • whichbar – caption

  • varagin – see waitbar header for explanation

OUTPUT

fout – handle output from waitbar() (WAITBAR_TYPE = 1)

unioncell(A, colA, B, colB)[source]

Return a cell which is the union of cell B to cell A given by a comparing

USAGE

AB = unioncell (A, colA, B, colB)

INPUTS
  • A – cell array A

  • colA – column of A for comparison

  • B – cell array B

  • colB – column of B for comparison

OUTPUT

AB – cell which is the union of cell B to cell A

updateStructData(origStruct, updateStruct)[source]

Update the struct in origStruct with the data from updateStruct

USAGE

updatedStruct = updateStruct (origStruct,updateStruct)

INPUTS
  • origStruct – The original Struct

  • updateStruct – The struct to update the information in origStruct.

OUTPUT

updatedStruct – The struct with the information from origStruct updated by the info from updateStruct