Import statement currently unsupported

10 ビュー (過去 30 日間)
Shankar Deka
Shankar Deka 2017 年 8 月 7 日
編集済み: Mohammad Shushtari 2020 年 8 月 18 日
Hello, I am trying to use Java Robot Class inside a Matlab Function Block in Simulink to simulate key-press and key-release. But I keep getting an error while running the simulink model: "Import statements are currently unsupported." My code looks something like this:
function y = fcn(u)
import java.awt.*;
import java.awt.event.*;
rob=Robot;
rob.keyPress(KeyEvent.VK_A)
rob.keyRelease(KeyEvent.VK_A)
y = [0 0];
If I simply write the above as a function in matlab or as a script, it works fine. I get the error only when trying to do it with the simulink block. Is there any work-around to avoid this problem? Or any fixes? I am using Matlab version 2017a.
Thanks in advance! -SD

採用された回答

Brian Hannan
Brian Hannan 2017 年 8 月 8 日
If you're using this block for simulation only, you can use coder.extrinsic to get around this. There's a discussion on this here.
  1 件のコメント
Shankar Deka
Shankar Deka 2017 年 8 月 10 日
Thank you very much! That works!

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

その他の回答 (1 件)

Adam Bazyl
Adam Bazyl 2017 年 9 月 19 日
Hello, could you show the code of the running program? Because I have the same problem but still have an error. Is that correct?
coder.extrinsic('import');
  1 件のコメント
Mohammad Shushtari
Mohammad Shushtari 2020 年 8 月 18 日
編集済み: Mohammad Shushtari 2020 年 8 月 18 日
Hi, did you find the solution to this problem?

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by