What does this MATLAB class to and why isn't it working on my PC?

后端 未结 1 1139
情书的邮戳
情书的邮戳 2021-01-25 23:22

The very first one in this documentation: http://www.mathworks.com/help/matlab/matlab_oop/getting-familiar-with-classes.html

The class is:

classdef Basic         


        
相关标签:
1条回答
  • 2021-01-25 23:31

    Your error message doesn't look correct compared with the code, whichever your missing a class constructor (as is mentioned at the half way down the help link):

    classdef BasicClass
      properties
        Value
      end
      methods
    
        % Class constructor -> which you can pass pi/3 into.
        function obj = BasicClass ( varargin )
          if nargin == 1
            obj.Value = varargin{1};
          end
        end
    
        % Your Methods
        function r = roundOff(obj)
          r = round([obj.Value],2);
        end
        function r = multiplyBy(obj,n)
          r = [obj.Value] * n;
        end
      end
    end
    
    0 讨论(0)
提交回复
热议问题