It's nothing new to ask such question. Since I've spent some hours reading on the documentation and available examples. But awkwardly, MATLAB seems not accept my code. So, I feel totally confused
classdef testclass
%UNTITLED Summary of this class goes here
% Detailed explanation goes here
properties
a =3;
b =4;
end
methods
function obj = testclass(a_inp, b_inp) %
obj.a = a_inp;
obj.b = b_inp;
end
output = plus(obj)
output = minus(obj)
end
end
and the function
function output = minus(obj)
output = obj.a-obj.b;
end
I think this is a typical test. But when I initialize the class, it comes this error
Error using testclass
Too many input arguments.
Error in class_call (line 2)
myclass = testclass(3,4 );
I create the class by myclass = testclass(3,4 );
what might be wrong in my code? plz help! I'm stuck!
@MyClassfolder scheme. The linesoutput = plus(obj)andoutput = minus(obj)in your classdef make no sense. - horchlerclass_call? And why are there extra spaces after your4? are you changing what the real inputs are? I can't replicate this. Can you callobj = testclass(3,4)from the command window? Also, there's no need to include function signatures if you're not specifying any method attributes likeStaticorAccess=private(I suppose it doesn't hurt but it looks weird). - horchler