MATLAB: How do i find the function value for different values of xi &Yi; where f=function​(x,y);i=1,​2,……..​……n (n may be 15, 50 or 100)

functionsmatlab function

How do i find the function value for different values of xi & Yi; where f= function(x,y); i=1,2,…………..n (n may be 15, 50 or 100)?

Best Answer

If xi and Yi are both vectors of values, and you want to find the result at each pair of values xi(J), Yi(K), then
[XI, YI] = ndgrid(xi, Yi);
results = arrayfun(@f, XI, YI);