Matlab: Multiple Columns, way to select closest to a value
===

I'm trying to analyze data sets that are obtained from CSV files.  After the data is read into matlab, I am left with a variable of my data only.  The number of columns and rows changes between each file.  Is there a way to average each column and then create a variable for the one with the closest average to a certain value? and then also select the columns directly before and after this middle column and create variables for them, as well as create a variable for the column with the lowest average?  Currently, I am selecting the columns manually and creating a variables for them that way.

For example:

I have this table of numbers.  (I used the same number in each column for sake of easy averaging in this example.

        1     2     3     4     5     

        1     2     3     4     5

        1     2     3     4     5

        1     2     3     4     5

        1     2     3     4     5

Let's say I want the column whose average is closest to 3.2

That column would be column 3 whose average is 3.  Then I would want the code to select the column before (column 2) and the column after (column 4).  As well as the column with the lowest average (column 1)

Thank you.
