1


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");
    }
}
--------------------------

http://www.weizmann.ac.il/matlab/techdoc/matlab_external/ch_java9.htmlによると、 matlabコードは簡単なはずですが、うまくいきません。したがって、matlab コードのヘルプは素晴らしいでしょう。

ありがとう

4

1 に答える 1

1

Matlab でのインポートを容易にするために、MAT ファイル形式を使用してデータを書き込むことをお勧めします。次に、ファイルを Matlab 変数にロードできるようになります。

于 2012-11-09T11:51:13.057 に答える