Your problem is that your data isn't in 'grid data' format. Gnuplot sees the data and plots it as lines instead of plotting it as a surface. Unfortunately, I don't know matlab, but here's some pseudo-code which should work (although may not be the most efficient way to write the data):
do iy=1 to ny
do ix=1 to nx
write gridx(ix,iy), gridy(ix,iy), data(ix,iy)
enddo
write blank line
enddo
Of course, if your grids can be expressed as 1D arrays (instead of 2D as above), you can just do the following (with appropriate loops):
write gridx(ix), gridy(iy), data(ix,iy)
Alternatively, you can use dgrid3d
in gnuplot. dgrid3d
interpolates non-grid data into grid data. By default, it interpolates to a 10x10 grid which as you noted is pretty coarse. You can increase this by set dgrid3d NX,NY
where NX
and NY
are the number of points on the x and y axes respectively.
Finally, if you don't want to mess with your datafile, you might want to consider using the following awk
script from the gnuplot FAQ (section 3.9):
#addblanks.awk
/^[[:blank:]]*#/ {next} # ignore comments (lines starting with #)
NF < 3 {next} # ignore lines which don't have at least 3 columns
$1 != prev {printf "\n"; prev=$1} # print blank line
{print} # print the line
Now to plot your surface:
set surface
splot "<awk -f addblanks.awk yourdatafile.dat"
griddata
format? What happens if youset dgrid3d
? Is the surface (approximately) correct? – mgilson