0

I am currently having problems calling a static method located in an m-file, through the octave command interface. The error I'm getting is error: invalid call to script path/to/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(). 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.

Any help is much appreciated, thanks in advance!

ShellFish
  • 4,351
  • 1
  • 20
  • 33
  • Even when the methods are static? I'm very new to Octave and Matlab but in Java the whole point of having static methods is to be able to call them without having to use an object... – ShellFish Nov 18 '14 at 23:24
  • My previous comment was wrong. – Oleg Nov 19 '14 at 00:33

1 Answers1

1

From the Octave FAQ: "Matlab classdef object oriented programming is not yet supported, though work is underway in a branch of the development tree." So the error is likely arising from the lack of classdef support, and the parser can't make sense of the call at all.

TroyHaskin
  • 8,361
  • 3
  • 22
  • 22
  • Actually you do not need a constructor. See 7th bullet point in http://uk.mathworks.com/help/matlab/matlab_oop/class-constructor-methods.html. Your link just says that you cannot have a constructor in a separate file. – Oleg Nov 19 '14 at 00:35
  • @OlegKomarov Ah, thank you. I guess I forgot that compilers/interpreters will provide a default constructor; a teacher one time told me never to do that, so I push it from my mind. – TroyHaskin Nov 19 '14 at 12:24