필터 지우기
필터 지우기

What does "@" do ?

조회 수: 578 (최근 30일)
H ZETT M
H ZETT M 2017년 1월 12일
댓글: Dyuman Joshi 2023년 10월 7일
So this is a simple question. I found some code that uses "@" and I looked it up in the matlab documentation, but I did not find it to be really helpfull. Can somebody explain to me what it does and when/how I want to use it ?

채택된 답변

Vandana Rajan
Vandana Rajan 2017년 1월 16일
편집: Walter Roberson 2023년 10월 6일
Hi,
You might have seen function handles.
A function handle is a MATLAB® data type that stores an association to a function.
To create a handle for a function, precede the function name with an @ sign. For example, if you have a function called myfunction, create a handle named f as follows:
>> f = @myfunction;
Now if you have a function like
function y = computeSquare(x)
y = x.^2;
end
>> f = @ComputerSquare;
>> a = 4;
>> b = f(a)
will give
b = 16
Please go through these 2 documentation links which very clearly explains about function handles.
Yet another use of the symbol '@' is as class folder designator. An @ sign can indicate the name of a class folder, such as
\@myclass\get.m
See the below link for more info.
  댓글 수: 10
Walter Roberson
Walter Roberson 2021년 10월 16일
편집: Walter Roberson 2022년 8월 23일
Rockford
Rockford 2022년 8월 23일
It should be computeSquare, not ComputerSquare.

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

추가 답변 (1개)

Amir Azadeh Ranjbar
Amir Azadeh Ranjbar 2023년 10월 6일
its function handle
func = @(x) x*2+10
func = function_handle with value:
@(x)x*2+10
func(5)
ans = 20
  댓글 수: 3
Amir Azadeh Ranjbar
Amir Azadeh Ranjbar 2023년 10월 7일
Well, this answer that was given (6 years ago) is more confusing....
Dyuman Joshi
Dyuman Joshi 2023년 10월 7일
What makes you think it is confusing? (let alone more confusing)
And your answer does not mention important details that the accepted answer provides.

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

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by