Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导出Java对象并将其导入matlab_Java_Matlab_Serialization - Fatal编程技术网

导出Java对象并将其导入matlab

导出Java对象并将其导入matlab,java,matlab,serialization,Java,Matlab,Serialization,我尝试将java中的大型数组输入到matlab中。 我的问题是,java程序太大,无法在matlab中运行java,因此我需要从java导出数据并将其加载到matlab中。有人试过这个吗 这就是我取得的成绩: 我已经编写了一个类,其中包含所有应该导出的值 ------- Export.java ------- import java.io.Serializable; public class Export implements Serializable { private double[][]


我尝试将java中的大型数组输入到matlab中。 我的问题是,java程序太大,无法在matlab中运行java,因此我需要从java导出数据并将其加载到matlab中。有人试过这个吗

这就是我取得的成绩: 我已经编写了一个类,其中包含所有应该导出的值

------- 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;}
}
--------------------------
和一个主要方法

------- 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");
    }
}
--------------------------
根据matlab代码应该很容易,但我不明白。因此,对matlab代码的任何帮助都将非常有用。


感谢

为了便于在Matlab中导入,我建议您使用。然后您将能够将文件转换为Matlab变量。

为了便于在Matlab中导入,我建议您使用。然后您将能够将文件转换为Matlab变量