Apply a callback to an array: Difference between revisions

m
(Added a solution for MATLAB)
Line 731:
 
=={{header|MATLAB}}==
There are two types of arrays in MATLAB: arrays and cell arrays. MATLAB includes two functions, one for each of these data types, that accomplish the specification for this task. For arrays, we use "arrayfun()"; for cell arrays we use "cellfun()".<br />
Example:
For both of these function the first argument is a function handle for the function we would like to apply to each element. The second argument is the array whose elements are modified by the function. The function can be any function, including user defined functions.
Anonymous user