add matlab / octave functions to load line-by-line nxy (or nxyz) data on a grid into a matrix

e.g. if a file 'foobar.dat' looks like this:
1 10 11
1 20 21
1 30 31
2 10 12
2 20 22
2 30 32
3 10 13
3 20 23
3 30 33
4 10 14
4 20 24
4 30 34

then you can use octave like that (with output below)
[data,x,y]=load_block_2d('foobar.dat')
data =

   11   21   31
   12   22   32
   13   23   33
   14   24   34

x =

   1
   2
   3
   4

y =

   10
   20
   30

I am sure there must a built-in function to do that, but I did not find it.