0

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?

Mengr
  • 129
  • 5
  • 2
    You may have better luck there https://mathematica.stackexchange.com/ – nicolallias Apr 08 '19 at 12:46
  • 1
    It would help if you explained what the code does – Luis Mendo Apr 08 '19 at 13:33
  • 2
    @nicolallias: I don't think the Mathematica crowd will be better at finding an appropriate MATLAB function. This question is likely off topic there. – Cris Luengo Apr 08 '19 at 14:52
  • KarryMa: You will have a better chance at a good answer if you explain what `Map` does in Mathematica, and what your code tries to accomplish. I don't know how many people here know both MATLAB and Mathematica well enough to answer your question as it is now. – Cris Luengo Apr 08 '19 at 14:54
  • I understand your shyness but this is not completely off-topic https://mathematica.stackexchange.com/search?q=matlab -> the best relevance topic is about trancoding between mathematica and matlab. Have a look at https://www.12000.org/my_notes/mma_matlab_control/KERNEL2/index.htm which I found on https://mathematica.stackexchange.com/a/44225 – nicolallias Apr 08 '19 at 14:58
  • There's a much broader issue with this question which is that the body doesn't match the title. Is this a question about achieving the equivalent to `Map`, as per the title - in which case, where is the MATLAB code to create the inputs that the `Map` equivalent needs to receive? Or is it about achieving `H1` as produced in Wolfram Language, as per the body - in which case a more detailed explanation of this code would make for a better question, since it doesn't look to me like a good MATLAB implementation would be that close in structure to this code outside the `Map` call. – Will Apr 08 '19 at 15:41
  • I got the answer I wanted,thank you all! – Mengr Apr 13 '19 at 03:28

1 Answers1

2

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!

Sebastian Dengler
  • 1,258
  • 13
  • 30