Creating graphs in Matlab and displaying them in a Java program

I have a requirement to create matrix plots and map these plots to JSP. The project was developed in Java, and so far all my operations related to matrices are performed using the MatLabControl API http://code.google.com/p/matlabcontrol/ .

I wanted to return the matrices created by MATLAB (especially the matrix of eigenvalues ​​and wavelets). MATLAB provides the im2java function, which converts the graph image from the MATLAB view to java.awt.Image. My code used to get image data in MatlabControl was as follows:

public Image produceEigenValueGraph(final double [][] matrix) {
final double [][] maxEigenValueMatrix =
            extractOutMaxEigenValues(matrix);
    Image matlabPlotImage = null;
    try {
        MatlabNumericArray matLabEigenValueMatrix =
                new MatlabNumericArray(maxEigenValueMatrix, null);
        matLabTypeConverter.setNumericArray("eigen", 
                                            matLabEigenValueMatrix);
        matLabProxy.setVariable("amountOfTime", matrix.length - 1);
        matLabProxy.eval("time");
        matLabProxy.eval("plot(time, eigen)");
        matLabProxy.eval("frame=getframe");
        final Object [] returnedMatlabArguements =
                matLabProxy.returningEval("im2java(frame.cdata)", 1);
        matlabPlotImage =
                (Image)returnedMatlabArguements[0];
    } catch (MatlabInvocationException mie) {
        mie.printStackTrace();
    }
    return matlabPlotImage;
}

The code returns a nested exception:

Caused by: java.io.WriteAbortedException: writing aborted; 
java.io.NotSerializableException: sun.awt.image.ToolkitImage

Which, in principle, will put an end to any hope of working on this code if I am not mistaken in my use.

N.B , java.awt.Image

:

    -Is the above code the correct/only way to return images to a java program from Matlab?
    -If it is what would be the best alternatives to using Matlab, Java API or otherwise?
+3
1

?

matlabPlotImage = (Image)returnedMatlabArguements[0];

"- / Java- Matlab?"

Java Matlab, java Matlab

final Object [] returnedMatlabArguements = matLabProxy.returningEval("im2java(frame.cdata)", 1);
matlabPlotImage = (Image)returnedMatlabArguements[0];

, . (jpg, png, tiff), matlab, java, File Image.

"- , Matlab, API Java ?"

Mathworks Java api , . http://math.nist.gov/javanumerics/jama/#Package

Apache Commons Math , . http://commons.apache.org/math/userguide/linear.html

java

Java

Java -?

0

All Articles