Is there a way to evaluate a function that takes an [x, y] vector as input over a grid of points?
Here is the function I want to evaluate:
Jfun = @(u) (17*u(1)^2)/2 - 14*u(1)*u(2) - 40*u(1) + 19*u(2)^2 - 20*u(2)
The reason I defined the function this way is so that I can find the minimum thus:
umin = fminsearch(Jfun,[0,0])
Now I want to make the contour plot.
Something like this perhaps:
x = linspace(-1,6);
y = linspace(-3,5);
[X,Y] = meshgrid(x,y);
But is there a way to compute Z without having to use nested for loops?
I tried this:
but it doesn't work. It simply returns 173.5000 which is Jfun([-1 -1]).