Archive for the ‘FAQ’ Category.

I need a certain Matlab function, where do I find it in UJMP?

UJMP supports many Matlab functions, but not all.
But you can execute Matlab from within UJMP when you use Linux:

Matlab.getInstance().setMatrix("matrixInMatlab", ujmpMatrix);
Matlab.getInstance().execute("result = matlabFunction(matrixInMatlab)");
Matrix m = Matlab.getInstance().getMatrix("result");

Unfortunately, this is not working in Windows.

You might have to tell UJMP through a parameter, where the program is installed:
-DMatlab="/opt/matlab/matlab"

Can I resize a matrix?

Resizing depends on the matrix implementation. A dense matrix is fixed in size, as the data is stored in a double[][] array.

However, some matrix implementations allow resizing. For example, you can create a sparse matrix with MatrixFactory.sparse(0, 0) and then change the size dynamically with matrix.setSize(5, 5). Note that sparse matrices are much slower than dense matrices.

It might be better to append one matrix to another for resizing:

Matrix matrix = Matrix.zeros(5, 5);
Matrix newRow = Matrix.zeros(1, 5);

Matrix biggerMatrix = matrix.appendVertically(newRow);

or

Matrix biggerMatrix = MatrixFactory.vertCat(matrix, newRow);

Can I instanciate a Matrix without specifying its size?

It is possible to create a zero size matrix:

Matrix m = MatrixFactory.zeros(0, 0);

Sorting the rows of a matrix does not work. The values are ordered [1, 10, 11, 2, 3, 4, 5] and not as I expected.

This happens when you sort a StringMatrix with numbers in it. Use convert(ValueType.DOUBLE) to transform the matrix into a DoubleMatrix before sorting.

Can I use UJMP with Java 1.4?

No, unfortunately not. UJMP is designed for Java 6 and uses generics and other features introduced in Java 5.0. Without modifications, it will not run with lower versions.