简体   繁体   English

从m文件(octave / matlab)调用静态方法

[英]Calling static method from m-file (octave/matlab)

I am currently having problems calling a static method located in an m-file, through the octave command interface. 我目前在通过octave命令界面调用位于m文件中的静态方法时遇到问题。 The error I'm getting is error: invalid call to script path/to/Test.m 我得到的error: invalid call to script path/to/Test.merror: invalid call to script path/to/Test.m

Test.m: Test.m:

classdef Test    
    methods(Static=true)
        function ret = test_function()
            ret = 0;
        end
    end
end

I am trying to call the method in the following way: > Test.test_function() . 我试图通过以下方式调用该方法: > Test.test_function() It's important to note that the script resides in the same directory in which I invoked the octave command, the script Test.m shows up using tab completion so the location is not at fault here I guess. 重要的是要注意,脚本位于我调用octave命令的目录中,脚本Test.m使用制表符补全显示,因此我猜这里的位置没有错。

Any help is much appreciated, thanks in advance! 非常感谢您的帮助,在此先感谢您!

From the Octave FAQ : "Matlab classdef object oriented programming is not yet supported, though work is underway in a branch of the development tree." 来自Octave常见问题解答 :“尽管在开发树的分支中正在进行工作,但尚不支持Matlab classdef面向对象的编程。” So the error is likely arising from the lack of classdef support, and the parser can't make sense of the call at all. 因此,错误可能是由于缺少classdef支持而引起的,并且解析器根本无法理解调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM