what is the meaning of @ in matlab code?

Hi all,
i just downloaded a matlab function from some website and saw something strange
if ~isa(A, 'function_handle')
AT = @(x) A'*x;
A = @(x) A*x;
end
what is the meaning of @?

댓글 수: 2

Kobi Aflalo
Kobi Aflalo 2019년 4월 23일
The link you sent is a general documentation Where is the explanation

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

 채택된 답변

Girish babu P
Girish babu P 2019년 8월 22일

1 개 추천

An anonymous function is like an inline function in traditional programming languages, defined within a single MATLAB statement. It consists of a single MATLAB expression and any number of input and output arguments.
You can define an anonymous function right at the MATLAB command line or within a function or script.
This way you can create simple functions without having to create a file for them.
The syntax for creating an anonymous function from an expression is
f = @(arglist)expression

댓글 수: 3

Guillaume
Guillaume 2019년 8월 22일
"An anonymous function is like an inline function in traditional programming languages"
As far as I know the only other programming languages that formerly define inline functions are C and C++, and these are nothing like anonymous functions.
Many languages do have anonymous function and/or lambdas. They're usually more powerful than matlab's (allowing branching/assignment/multiple statements).
Unless all your anonymous function does is just call another function with multiple outputs, it is actually impossible to create an anonymous function with multiple outputs in matlab.
Girish babu P
Girish babu P 2019년 8월 26일
편집: Guillaume 2019년 8월 26일
f = @myfunction;
Now if you have a function like
function y = compSqure(x)
y = x.^2;
end
f = @compSqure;
a = 4;
b = f(a)
will give
b = 16
plz gothrough this links.
Guillaume
Guillaume 2019년 8월 26일
I have no idea what point you're trying to make but note that you started talking about anonymous function, your new comment demonstrates function handles which are not the same as anonymous functions (despite both using the symbol @)

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

추가 답변 (1개)

Satish Shenkar
Satish Shenkar 2021년 3월 14일

0 개 추천

how to matrix multiplication

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2019년 4월 23일

답변:

2021년 3월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by