Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline anonymous function in Matlab? [duplicate]

Is it possible to create multiline anonymous function in Matlab?

There are no appropriate examples in documentation, but also no direct denials. In web discussions I found some derisions of askers as if it silly wish. Nowadays, when most languages introducing lambda expressions with multiline capability this looks strange.

like image 400
Suzan Cioc Avatar asked Mar 21 '15 08:03

Suzan Cioc


People also ask

Can anonymous functions have multiple outputs Matlab?

but anonymous functions are not allowed more than one outputs. This is clearly a simplified example, the application is for a nonlinear programming problem where out1 is the objective function and out2 is the gradient calculation.

Can anonymous functions have multiple inputs?

Anonymous functions can accept multiple inputs and return one output. They can contain only a single executable statement. For example, create a handle to an anonymous function that finds the square of a number: sqr = @(x) x.

How do you assign an anonymous function to a variable?

We write the anonymous function in Javascript by writing function() followed by the parentheses, where we may pass the parameters, and skipping the function name. Then in a pair of curly braces {}, we write our desired code. Finally, we assign this function to a variable.

Is it right to pass an unknown function as an argument to another function?

Using anonymous functions as arguments Note that functions are first-class citizens in JavaScript. Therefore, you can pass a function to another function as an argument.


1 Answers

No, unfortunately this is not possible.

like image 132
Ratbert Avatar answered Oct 01 '22 19:10

Ratbert