eng.setDebugging((byte) 0);
long[] engineHandle = eng.open();
eng.evalString(engineHandle, "clear");
DoubleMatrixToken tx = new DoubleMatrixToken(
new double[][] { { 1, 2, 3 } });
System.out.println("\nNote: All data output is via "
+ "Token.toString() on tokens");
System.out.println("that are put/get from the matlab engineHandle.");
System.out.println("\nCreate 1x3 double matrix x:");
eng.put(engineHandle, "x", tx);
System.out.println("x = " + tx.toString());
System.out.println("Eval: y = x.*x;");
eng.evalString(engineHandle, "y = x.*x;");
DoubleMatrixToken ty = (DoubleMatrixToken) eng.get(engineHandle, "y");
System.out.println("y = " + ty.toString());
System.out.println("\nCreate 2x3 double matrix x:");
tx = new DoubleMatrixToken(new double[][] { { 1, 2, 3 }, { 4, 5, 6 } });
eng.put(engineHandle, "x", tx);
System.out.println("x = " + tx.toString());
System.out.println("Eval: y = x.*x;");
eng.evalString(engineHandle, "y = x.*x;");
ty = (DoubleMatrixToken) eng.get(engineHandle, "y");
System.out.println("y = " + ty.toString());
System.out.println("\nEval: z = exp(j*pi/2*x);");
eng.evalString(engineHandle, "z = exp(j*pi/2*x);");
ComplexMatrixToken tz = (ComplexMatrixToken) eng.get(engineHandle, "z");