matlabmathematica-8

What is the MATLAB equivalent of Mathematica's Map?


The Mathematica code is as follows:

In:Map[Function[x, x + 1], {1, 2, 3}]
Out:{2, 3, 4}

How can I use a similar method to realise this expression in MATLAB?


Solution

  • I don't know if it's still relevant, but it looks like you are searching for the arrayfun() function:

    y = arrayfun(@(x) x+1, [1 2 3])
    

    Hope it helps!