1


I try to get large arrays from java into matlab. My problem ist, the java program is to large to run java in matlab, so I need to export the data from java and load it into matlab. Do anyone tried this?

This is how far I got: I've wrote a class containing all values that should be exported

------- Export.java -------
import java.io.Serializable;
public class Export implements Serializable {
private double[][] values;
private String description;
public Export(String description,double[][] values){
    this.description=description;
    this.values=values;
}
public String getDescription(){return description;}
public double[][] getValues(){return values;}
}
--------------------------

And an main methode

------- StartPoint.java -------
public class StartPoint {
public static void main(String[] args) {
    Export serial= new Export("description",new double[][]{{1,2},{3,4}});
      OutputStream file;
    try {
        file = new FileOutputStream( "object.ser" );
        OutputStream buffer = new BufferedOutputStream( file );
        ObjectOutput output = new ObjectOutputStream( buffer );
        output.writeObject(serial);
        output.close();
    } 
    catch (FileNotFoundException e) {e.printStackTrace();}
    catch (IOException e) {e.printStackTrace();}
    System.out.println("done");
    }
}
--------------------------

Accroding to http://www.weizmann.ac.il/matlab/techdoc/matlab_external/ch_java9.html the matlab-code should be easy, but I don't get ist. So any help for the matlab code would be great.

Thanks

1 Answer 1

1

To facilitate the import in Matlab I suggest that you write the data using the MAT-file format. Then you will be able to load the files into Matlab variables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.