Does Matlab support function-objects? -


trying figure out if have access function object programming techniques use in our matlab scripts. analogous .net's func type, or python's function objects. matlab give functions first class object status?

matlab have function handles can passed other functions. 1 example, function fzero find zero-crossing of function give first argument. function handles can stored in variables, cell-arrays or structs. matlab has anonymous functions, similar python's lambda expressions. seems functions in matlab have properties considered first class.

some random examples:

>> sq = @(x) x^2 - 2 sq =      @(x)x^2-2  >> fzero(sq, 1) ans =     1.4142  >> class(sq) ans = function_handle  >> functions = {@(x) 2 * x, @(y) 3 * y, @exp} functions =      @(x)2*x    @(y)3*y    @exp  >> functions{2}(10) ans =     30  >> functions{3}(1) ans =     2.7183 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -