필터 지우기
필터 지우기

what @ does in MATLAB?

조회 수: 45 (최근 30일)
Md Jonayet
Md Jonayet 2023년 4월 19일
편집: per isakson 2023년 4월 20일
I have a class name VI_Lecroy.
function obj = VI_SDA6000(varargin)
obj = obj@VI_LeCroy(varargin{:});
end
What this @ does?
  댓글 수: 2
Luca Ferro
Luca Ferro 2023년 4월 19일
i think it is a function handle but i might be mistaken
Walter Roberson
Walter Roberson 2023년 4월 19일
@ in other contexts is used for function handles, but in the context of being in the middle of a pair of words, is a superclass reference.

댓글을 달려면 로그인하십시오.

채택된 답변

chicken vector
chicken vector 2023년 4월 19일
편집: chicken vector 2023년 4월 19일
In this case @ is used to call a superclass method from a subclass.
Consider the classes Food and Donut, such that Donut is a subclass of Food.
If Food has a method eat, you can call this method from the subclass Donut using the operator @:
%% Food class:
classdef Food
methods
% Constructor
function obj = Food(varargin)
...
end
function eatenFood = eat(varargin)
...
end
end
end
%% Donut class:
classdef Donut < Food
methods
% Constructor
function obj = Donut(varargin)
...
end
function eatenDonut = eat(varargin)
eatenDonut = eat@Food(varargin)
end
end
end
In particular, obj@Food calls the constructor method that is used to define class instances.
This is the method that has the same name of the class itself.
It follows that:
function obj = VI_SDA6000(varargin)
obj = obj@VI_LeCroy(varargin{:});
end
implies that the instances of the class VI_SDA6000 are constructed in the same way as done in VI_LeCroy.
You can find more detailes here.
  댓글 수: 1
Adam Danz
Adam Danz 2023년 4월 19일
Another good reference to add to @chicken vector's answer:

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by