Global minimum in a huge convex matrix by using small matrices
<p>I have a function J(x,y,z) that gives me the result of those coordinates. This function is convex. What is needed from me is to find the minimum value of this huge matrix. 
At first I tried to loop through all of them, calculate then search with min function, but that takes too long ... </p>

<p>so I decided to take advantage of the convexity. 
<img src="https://i.stack.imgur.com/ea8cA.png" alt="Visual example"></p>

<p>Take a random(for now) set of coordinates, that will be the center of my small 3x3x3 matrice, find the local minimum and make it the center for the next matrice. This will continue until we reach the global minimum. </p>

<p>Another issue is that the function is not perfectly convex, so this problem can appear as well</p>

<p><img src="https://i.stack.imgur.com/h94Ip.png" alt="fake and real min"></p>

<p>so I'm thinking of a control measure, when it finds a fake minimum, increase the search range to make sure of it. 
How would you advise me to go with it? Is this approach good? Or should I look into something else?</p>

<p><strong>This is something I started myself but I am fairly new to Matlab and I am not sure how to continue.</strong> </p>

<pre><code>clear all
clc
min=100;

%the initial size of the search matrix 2*level +1
level=1;
i=input('Enter the starting coordinate for i (X) : ');
j=input('Enter the starting coordinate for j (Y) : ');
k=input('Enter the starting coordinate for k (Z) : ');

for m=i-level:i+level
    for n=j-level:j+level
        for p=k-level:k+level
            A(m,n,p)=J(m,n,p);
            if A(m,n,p)&lt;min
                min=A(m,n,p);
            end
        end
    end
end
display(min, 'Minim');

[r,c,d] = ind2sub(size(A),find(A ==min));

display(r,'X');
display(c,'Y');
display(d,'Z');
</code></pre>

<p><strong>Any guidance, improvement and constructive criticism are appreciated. Thanks in advance.</strong></p>