在MATLAB中创建类的实例时,at@是什么意思?
例如:在MATLAB中创建类的实例时,at@是什么意思?,matlab,oop,Matlab,Oop,例如: function s = slexpdatasetSLAP() s = s@slexpdataset('slapCC','SLAP dataset for collective classification'); %slexpdataset is a class defined in another .m file s.discription ='CC'; end 据我所知,@被用作在MATLAB中创建函数句柄,但显然,这种解释不适用于这种情况。那么,@的意思是什么呢?
function s = slexpdatasetSLAP()
s = s@slexpdataset('slapCC','SLAP dataset for collective classification'); %slexpdataset is a class defined in another .m file
s.discription ='CC';
end
据我所知,
@
被用作在MATLAB中创建函数句柄,但显然,这种解释不适用于这种情况。那么,@
的意思是什么呢?这是调用的语法
通常,您会使用以下语法
outputs = methodName@superclassname(obj, input, arguments)
但是,调用构造函数有点不同,因为在上面的示例中,使用对象实例的变量名代替methodName
obj = obj@superclassname(input, arguments)
在您的例子中,不是使用
obj
,而是使用s
作为变量来引用类实例(因为您将其定义为构造函数的输出),因此您实际上是在调用slexpdataset
的构造函数,并将所示参数列表传递给它。这是调用的语法
通常,您会使用以下语法
outputs = methodName@superclassname(obj, input, arguments)
但是,调用构造函数有点不同,因为在上面的示例中,使用对象实例的变量名代替methodName
obj = obj@superclassname(input, arguments)
在您的例子中,不是使用obj
,而是使用s
作为引用类实例的变量(因为您将其定义为构造函数的输出),因此实际上是调用slexpdataset
的构造函数,并将所示参数列表传递给它