In matlab, how do I apply a function of two arguments to two cellarrays of equal length?

Posted by kaleidomedallion on Stack Overflow See other posts from Stack Overflow or by kaleidomedallion
Published on 2010-05-17T02:09:37Z Indexed on 2010/05/17 2:20 UTC
Read the original article Hit count: 247

Filed under:
|
|
|

So I have two cell arrays:

A = {2 2 2 2}
B = {[1 2] [3 2] [5 5] [7 7]}

and a function of two arguments:

F = @(a, b) [a * b(1), (b(2) / 3), (b(1) + a) * 22]

And I want to apply the function to the two cell arrays like so:

idealfun(F, A, B)

and have it do the right thing (return a cell array with four cells of 1x3 vectors). Any ideas how to find/write idealfun?

© Stack Overflow or respective owner

Related posts about matlab

Related posts about function