How can I get com.mathworks.engine.* package ?

8 ビュー (過去 30 日間)
Al Mamun
Al Mamun 2017 年 12 月 14 日
コメント済み: Al Mamun 2017 年 12 月 15 日
Here is my code
import com.mathworks.engine.*;
import java.util.Arrays;
public class javaPutVar {
public static void main(String[] args) throws Exception {
MatlabEngine eng = MatlabEngine.startMatlab();
eng.putVariable("x", 7.0);
eng.putVariable("y", 3.0);
eng.eval("z = complex(x, y);");
String[] w = eng.feval("who");
System.out.println("MATLAB workspace variables " + Arrays.toString(w));
eng.close();
}
}
This code is showing error:
javaPutVar.java:1: error: package com.mathworks.engine does not exist
import com.mathworks.engine.*;
^
javaPutVar.java:6: error: cannot find symbol
MatlabEngine eng = MatlabEngine.startMatlab();
^
symbol: class MatlabEngine
location: class javaPutVar
javaPutVar.java:6: error: cannot find symbol
MatlabEngine eng = MatlabEngine.startMatlab();
^
symbol: variable MatlabEngine
location: class javaPutVar
3 errors
How can I fix this errors? How can I get com.mathworks.engine.* package ?

採用された回答

Steven Lord
Steven Lord 2017 年 12 月 14 日
Are you using release R2016b or later? According to the documentation and the Release Notes that's when this functionality was introduced.
  4 件のコメント
Steven Lord
Steven Lord 2017 年 12 月 14 日
You should already have it. Have you performed the setup steps necessary to get started using the API?
  1. Open the documentation in your installation using the doc command.
  2. In the documentation for MATLAB, click on "Advanced Software Development".
  3. On the "Advanced Software Development" page click on "MATLAB API for Other Languages".
  4. On the "MATLAB API for Other Languages" page click on "MATLAB Engine API for Java".
  5. On the "MATLAB Engine API for Java" page click on "Build Java Engine Programs" in the Getting Started section of the Topics.
  6. Follow the steps under the General Requirements section and then read the section for the operating system you're using.
Al Mamun
Al Mamun 2017 年 12 月 15 日
Thank you, your answer is highly helpful. But when I try to run my code this error is showing.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCall MATLAB from Java についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by