不能在Matlab 7.1.0.246(R14)中调用静态方法

时间:2016-05-21 01:30:59

标签: matlab static-methods

这是一个简单的.m文件。保存到“temp.m”。

在Matlab 7.12.0(R2011a)中,我可以调用temp.t0()或temp.t1(),它会打印出预期的结果。但是在Matlab 7.1.0.246(R14)中。它显示了这个错误:

  
    

temp.t0()???无法使用{}或索引函数,脚本或类temp。索引。

  

是因为Matlab版本很低,并且它不支持调用静态方法吗?

以下是temp.m

的源代码
classdef temp
    methods (Static)
        function [] = t0()
            fprintf('function t0\n');
        end
        function [] = t1()
            fprintf('function t1\n');
        end
    end
end

1 个答案:

答案 0 :(得分:2)

MCOS,面向对象编程的classdef语法是not introduced until R2008a(MATLAB 7.6),所以MATLAB 7.1 肯定不支持你要做的事情,因此错误。

您拥有的旧版本确实支持@classname folders类定义;但是,在R2008a中引入MCOS类之前,不支持静态方法。