top of page
  • Writer's pictureAdisorn O.

IN-LINE VS. ANONYMOUS FUNCTION

Updated: Mar 19, 2023

Sometimes we must define a short function for using with our main program or inside the user function. The in-line function is made for this purpose. It is easy to define a single return value function without creating an m-file. The syntax of the in-line function is in the form.


f = inline('expression', 'p1', 'p2',...)


An anonymous function is an advanced form of an in-line function. It requires no use of quotation marks for the expression and input arguments.


f = @(p1,p2,...) expression


Just specify f(p1,p2,...) to call the function.


Both in-line and anonymous functions can return only a single value. We cannot call for other functions inside them.




17 views

Comments


bottom of page