mean like many functions in matlab operates along the first non-scalar dimension of a matrix. Your h is a 2D matrix, so the first non-scalar dimension is the rows and mean gives you the average across the rows (hence the average of each column).
If you're using a reasonably modern version of matlab (2018b or later) you can tell mean to operate across all the dimensions at once:
In older versions, you can either call mean twice:
but be careful that it doesn't work for non-linear functions such as std. Instead you can reshape your matrix so it has only one dimension:
or use the mean2 function which gives you the mean of all pixels of a 2D image:
I recommend the first ('all' option) or 3rd option ( use (:)) for older versions.
Best Answer