您可以使用 MATLAB Builder JA 从 MATLAB 对象创建 Java 对象吗
我正在尝试使用 MATLAB 对象进行概念验证。我想看看您是否可以在 Java 代码中使用如下所示的 MATLAB 对象。我们需要 MATLAB 对象来保持状态。我已使用 MATLAB Builder JA 在 MATLAB 中创建函数并在 Java 中访问它们,但我不确定是否可以以相同的方式发送 MATLAB 类。
classdef TestObject < handle
properties (SetAccess = private)
number = 0;
end
methods
function addToNumber(TO, x)
TO.number = TO.number + x;
end
end
end % classdef
I'm trying to do a proof of concept with MATLAB objects. I want to see if you can use MATLAB objects like the one below in Java code. We need the MATLAB objects to keep state. I've used MATLAB Builder JA to create functions in MATLAB and access them in Java, but I'm not sure if MATLAB classes can be sent the same way.
classdef TestObject < handle
properties (SetAccess = private)
number = 0;
end
methods
function addToNumber(TO, x)
TO.number = TO.number + x;
end
end
end % classdef
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信你目前还做不到这一点。您可以使用 MATLAB 对象,但如果您想调用它们的方法,您需要为它们创建一个函数包装器,并且它们不会在调用之间保留状态。
我认为我的说法是正确的,使用 .NET 的 Builder,而不是 Java 的 Builder,您可以将 .NET 对象跨越边界传递给 MATLAB,您可以使用该功能来保留您将执行的任何状态与 MATLAB 对象。您也许可以使用 Builder for JA 对 Java 对象执行类似的操作,但我从未尝试过。
I believe you currently can't do this. You can use MATLAB objects, but if you want to call their methods you need to create a functional wrapper for them, and they won't keep state between calls.
I think I'm right in saying that with Builder for .NET, rather than for Java, you have the ability to pass a .NET object across the boundary to MATLAB, a functionality which you can use to keep whatever state you would have done with a MATLAB object. You might be able to do something similar with a Java object using Builder for JA, but I've never tried it.