Q:

Import file in Matlab with headers

Suppose we have following data
Month   High     Low    Average
    1   45.36   33.84   39.6
    2   50.87   35.98   43.43
    3   56.05   38.55   47.3
    4   60.49   41.36   50.92
    5   67.17   46.92   57.05
    6   73.82   52.8    63.31
    7   79.72   56.43   68.07
    8   80.14   56.79   68.47
    9   74.54   51.83   63.18
    10  64.08   44.95   54.52
    11  52.66   39.54   46.1
    12  45.59   34.75   40.17

I know that I need the function fprintf to import a file which contains headers. We have 4 columns and  12 rows, so how can I use the fprintf function or which function should I use to import data successfully? There is this code, but I am not sure if it is reliable. Can I use something from Matlab itself?

A:

use fscanf for files and sscanf for strings. The syntax is similar to that of fprintf you're familiar with. The matlab documentation provides a comprehensive set of examples to get you started.
Less flexible, but sufficient for your use would probably be dlmread.
assuming your data is in data.txt and you'd like to skip the first row (as it's the header) do:
>> x = dlmread('data.txt', '', 1, 0)

x =

    1.0000   45.3600   33.8400   39.6000
    2.0000   50.8700   35.9800   43.4300
    3.0000   56.0500   38.5500   47.3000
    4.0000   60.4900   41.3600   50.9200
    5.0000   67.1700   46.9200   57.0500
    6.0000   73.8200   52.8000   63.3100
    7.0000   79.7200   56.4300   68.0700
    8.0000   80.1400   56.7900   68.4700
    9.0000   74.5400   51.8300   63.1800
   10.0000   64.0800   44.9500   54.5200
   11.0000   52.6600   39.5400   46.1000
   12.0000   45.5900   34.7500   40.1700

--edit--
from the docs:

dlmread(filename, delimiter, R, C) reads data whose upper left corner
  is at row R and column C in the file, using the specified delimiter.
  The filename input is a string enclosed in single quotes. 
  Values R and C are zero-based, so that R=0, C=0 specifies the first
  value in the file.

Now as we would like to use the default delimiter (any number of spaces), but must provide one as we're also providing Row and Col arguments, we provide an empty string.

