How can I plot (a 3D plot) a matrix in Gnuplot having such data structure, using the first row and column as a x and y ticks (the first number of the first row is the number
Exactly this data format can be read in with matrix nonuniform:
matrix nonuniform
set view 50,20 set ticslevel 0 splot 'data.txt' matrix nonuniform with lines t ''
This generates the correct tics, like specified in the data file: