有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Java函数在Matlab类中变得未定义

我开始在matlab中使用OOP。然而,在代码中使用java对象让我有点头疼。 具体来说,我在尝试运行testClass时遇到了这个错误。开始():

Undefined function 'SessionSettings' for input arguments of type 'char'.

上述函数存在于jar中,该jar被导入,如果在matlab类之外运行,代码运行良好。 下面是课程:

classdef testClass

 properties
     data
 end

 methods

      function obj = testClass()
         % class constructor
         javaaddpath /home/test/test-examples-1.5.3.jar;
         import test.examples.thingy.*;

      end


     function ret = start()
         % 
         settings = sessionSettings('configFilePath');
      end
 end

end

共 (1) 个答案

  1. # 1 楼答案

    引用^{}的文件:

    The import function only affects the import list of the function within which it is used. When invoked at the command prompt, import uses the import list for the MATLAB® command environment. If import is used in a script invoked from a function, it affects the import list of the function. If import is used in a script that is invoked from the command prompt, it affects the import list for the command environment.

    The import list of a function is persistent across calls to that function and is only cleared when the function is cleared.

    这意味着您的方法start()将看到一个空的导入列表