MATLAB: Imagesc/Contourf and plotting correctly

3d matrixplotting

Thanks in advance for the help.
I have a series of coordinates in latitude, longitude, and depth (respectively called lat, long, and depth) and associated at each one of these points P(lat,long,depth) I have a value. The values for each of these points in contained in a 3d matrix called misfit(lat,long,depth). The idea is to make several imagesc (or contourf) plots to at varying depths to get an idea of my results and to have on each plot a point marking the minimum of the misfit (the matrix mentioned above). I contain the value and the coordinates of the minimum misfit (in that respective order) in the variable mini.
The problem is that when I do: figure; hold on imagesc(lat, long, misfit(:,:,mini(4))); plot(lat(mini(2)), long(mini(3)), 'ok', 'markersize', 15, 'markerfacecolor', 'k'); hold off
I have a surface that's minimum does not correspond at all to the point I plotted. When I go to the data cursor and go to the location of mini, it gives me back a value that is not at all the minimum value I want.
What am I missing here?

Best Answer

I was expecting to see the same value and associated coordinates that I found from the misfit matrix directly, however the data cursor gave me different coordinates (and whether they're close or not doesn't matter as they should be exactly the same).
I was expecting imagesc() to plot exactly the coordinates I gave it with the associated values it found in misfit. However I found out that the problem stemmed from the fact that imagesc() doesn't actually use the lat/long cooridnate vectors I fed it and instead takes the starting point, the ending point, and the length of lat/long and then constructs the following vector to use as the coordinates of the misfit matrix:
[lat(1):(lat(end)-lat(1))/length(lat):lat(end)]
My problem was to use lat/long vectors that did not have a constant interval (doing a monte carlo search) so imagesc() ended up using its own lat/long vectors and everything got misplaced and skewed. Sorta disappointing imagesc() would act like this, but oh well.
Thank you Walter and Teja for your responses.
PS. Thanks for the tip with min(misfit(:))! I always found min(min(min( ad infinitum was really clunky.