Package adams.data.matlab
Class MatlabUtils
- java.lang.Object
-
- adams.data.matlab.MatlabUtils
-
public class MatlabUtils extends Object
Helper class for Matlab data structures.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description MatlabUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringarrayDimensionsToString(us.hebi.matlab.mat.types.Array array)Generates a string representation of the array dimensions, uses 'x' as separator.static StringarrayDimensionsToString(us.hebi.matlab.mat.types.Array array, String separator)Generates a string representation of the array dimensions.static StringcharToString(us.hebi.matlab.mat.types.Char matChar)Converts a character cell into a string.static ObjectgetElement(us.hebi.matlab.mat.types.Matrix source, int[] index, ArrayElementType type)Returns the element according to the specified type.static booleanincrement(int[] index, int[] dims)Increments the index.static booleanincrement(int[] index, int[] dims, int[] open)Increments the index.static StringsetElement(us.hebi.matlab.mat.types.Matrix target, int[] index, ArrayElementType type, Object value)Sets the element according to the specified type.static voidtransfer(us.hebi.matlab.mat.types.Matrix source, int[] indexSource, int[] dimsSource, int[] openSource, us.hebi.matlab.mat.types.Matrix target, int[] indexTarget, int[] dimsTarget, int[] openTarget, ArrayElementType type)For transferring the subset from the original matrix into the new one.static voidtransfer(us.hebi.matlab.mat.types.Matrix source, int[] dimsSource, int[] openSource, int[] indexSource, us.hebi.matlab.mat.types.Matrix target, int[] dimsTarget, ArrayElementType type)For transferring the subset from the original matrix into the new one.static voidtransfer(us.hebi.matlab.mat.types.Matrix source, int[] sourceIndex, us.hebi.matlab.mat.types.Matrix target, int[] targetIndex, ArrayElementType type)Transfers a single cell from one matrix to another.
-
-
-
Method Detail
-
charToString
public static String charToString(us.hebi.matlab.mat.types.Char matChar)
Converts a character cell into a string. Rows are interpreted as lines.- Parameters:
matChar- the cell to convert- Returns:
- the generated string
-
increment
public static boolean increment(int[] index, int[] dims)Increments the index.- Parameters:
index- the current indexdims- the dimensions (ie max values)- Returns:
- true if finished
-
increment
public static boolean increment(int[] index, int[] dims, int[] open)Increments the index.- Parameters:
index- the current indexdims- the dimensions (ie max values)open- the indices that are "open" to be incremented- Returns:
- true if finished
-
transfer
public static void transfer(us.hebi.matlab.mat.types.Matrix source, int[] sourceIndex, us.hebi.matlab.mat.types.Matrix target, int[] targetIndex, ArrayElementType type)Transfers a single cell from one matrix to another.- Parameters:
source- the source matrixsourceIndex- the index of the cell in the source matrixtarget- the target matrixtargetIndex- the index of the cell in the target matrixtype- the type of element to transfer
-
transfer
public static void transfer(us.hebi.matlab.mat.types.Matrix source, int[] dimsSource, int[] openSource, int[] indexSource, us.hebi.matlab.mat.types.Matrix target, int[] dimsTarget, ArrayElementType type)For transferring the subset from the original matrix into the new one.- Parameters:
source- the source matrixdimsSource- the dimensions of the source matrixopenSource- the indices of the "open" dimensionsindexSource- the indices in the source to usetarget- the target matrixdimsTarget- the dimensions of the target matrixtype- the element type to use for transferring the data
-
transfer
public static void transfer(us.hebi.matlab.mat.types.Matrix source, int[] indexSource, int[] dimsSource, int[] openSource, us.hebi.matlab.mat.types.Matrix target, int[] indexTarget, int[] dimsTarget, int[] openTarget, ArrayElementType type)For transferring the subset from the original matrix into the new one.- Parameters:
source- the source matrixindexSource- the source index template to use, initializes with all 0s if nulldimsSource- the dimensions of the source matrixopenSource- the indices of the "open" dimensionstarget- the target matrixindexTarget- the target index template to use, initializes with all 0s if nulldimsTarget- the dimensions of the target matrixopenTarget- the indices of the "open" dimensionstype- the element type to use for transferring the data
-
getElement
public static Object getElement(us.hebi.matlab.mat.types.Matrix source, int[] index, ArrayElementType type)
Returns the element according to the specified type.- Parameters:
source- the matrix to get the element fromindex- the index of the elementtype- the type of element- Returns:
- the value
-
setElement
public static String setElement(us.hebi.matlab.mat.types.Matrix target, int[] index, ArrayElementType type, Object value)
Sets the element according to the specified type.- Parameters:
target- the matrix to set the element inindex- the index of the elementtype- the type of elementvalue- the value of the element, gets automatically parsed if string- Returns:
- null if successfully set, otherwise error message
-
arrayDimensionsToString
public static String arrayDimensionsToString(us.hebi.matlab.mat.types.Array array)
Generates a string representation of the array dimensions, uses 'x' as separator.- Parameters:
array- the array to generate the dimensions for- Returns:
- the generated string
-
arrayDimensionsToString
public static String arrayDimensionsToString(us.hebi.matlab.mat.types.Array array, String separator)
Generates a string representation of the array dimensions.- Parameters:
array- the array to generate the dimensions forseparator- the separator to use for the dimensions- Returns:
- the generated string
-
-