karry
karry

Reputation: 139

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?

Upvotes: 0

Views: 158

Answers (1)

Sebastian Dengler
Sebastian Dengler

Reputation: 1308

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!

Upvotes: 2

Related Questions