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");
System.out.println("z = " + tz.toString());
System.out.println("\nEval: w = z';");
eng.evalString(engineHandle, "w = z';");
ComplexMatrixToken tw = (ComplexMatrixToken) eng.get(engineHandle, "w");
System.out.println("w = " + tw.toString());
System.out.println("\nCreate 1xn string s:");
StringToken ts = new StringToken("a string");
System.out.println("s = " + ts.toString());
eng.put(engineHandle, "s", ts);
System.out.println("\nEval: rc = [s;s];");
eng.evalString(engineHandle, "rc = [s;s];");
Token ta = eng.get(engineHandle, "rc");
System.out.println("rc = " + ta.toString());
System.out.println("\nCreate 2xn string s:");
ta = new ArrayToken(new Token[] { new StringToken("str one"),
new StringToken("str two") });
System.out.println("s = " + ta.toString());
eng.put(engineHandle, "s", ta);
System.out.println("\nEval: rr = [s,s];");
eng.evalString(engineHandle, "rr = [s,s];");
ta = eng.get(engineHandle, "rr");
System.out.println("rr = " + ta.toString());
System.out.println("\nCreate 1x1 struct r (RecordToken):");
RecordToken tr = new RecordToken(new String[] { "x", "r", "s" },
new Token[] {
tx,
new RecordToken(new String[] { "a" },
new Token[] { new IntToken() }), ts });
System.out.println("r = " + tr.toString());
eng.put(engineHandle, "r", tr);
Token t = eng.get(engineHandle, "r");
System.out.println("\nRead back 1x1 struct r into RecordToken t:");
System.out.println("t = " + t.toString());
System.out.println("\nEval: ta = [r,r,r;r,r,r];");
eng.evalString(engineHandle, "ta = [r,r,r;r,r,r];");
t = eng.get(engineHandle, "ta");
System.out.println("\nRead 2x3 struct ta into ArrayToken "
+ "of ArrayToken of RecordTokens:");
System.out.println("ta = " + t.toString());
System.out.println("\nCreate 1x3 cell array from ta, "
+ "an ArrayToken of RecordTokens:");
RecordToken r1 = new RecordToken(new String[] { "a" },
new Token[] { new ComplexMatrixToken(new Complex[][] { {
new Complex(1.0, 1.0), new Complex(2.0, 2.0) } }) });
RecordToken r2 = new RecordToken(new String[] { "a" },
new Token[] { new ComplexMatrixToken(new Complex[][] { {
new Complex(3.0, 3.0), new Complex(4.0, 4.0) } }) });
RecordToken r3 = new RecordToken(new String[] { "a" },
new Token[] { new ComplexMatrixToken(new Complex[][] { {
new Complex(5.0, 5.0), new Complex(6.0, 6.0) } }) });
ta = new ArrayToken(new Token[] { r1, r2, r3 });
System.out.println("ta = " + ta.toString());
eng.put(engineHandle, "ta", ta);
eng.evalString(engineHandle, "tb = ta;");