MATLAB: How to evaluate an array of function handles at different points

cell arrayevaluatefunction handle

I have a cell array of 3 functions handles
phi={@ (x,y) 1-x-y,@ (x,y) x,@(x,y) y}
I need to evaluate it at 4 different points (0,0) (1,0) (0,1) and (1/3 1/3)
q=[0 1 0 1/3;0 0 1 1/3]
to create an 3×4 array of values where each row represents a function at four different points
How do I do it?
Thanks

Best Answer

This is a case where a for loop would probably be fastest. You could instead use
cell2mat( arrayfun( @(x,y) [phi{1}(x,y), phi{2}(x,y), phi{3}(x,y), phi{4}(x,y)], q(1,:).', q(2,:).', 'Uniform', 0 ) )
but arrayfun is going to be slower than a for loop.