MATLAB: Fitting 2d data set fit function is not working

fit

Hi,
this is my data set and I wanted to try to get a fit for it.
well, did not work with
fit([x,y],z,'poly23');
first it said: Dimensions of matrices being concatenated are not consistent.
then I made x and y the same length and
it said: Y must be a column vector.
And now I am stack. help please.
thanks

Best Answer

The problem is that your z data is defined in a grid while your x and y define only the vectors of this grid. If you first actually create the grid you will be able to create the model
[xmesh,ymesh] = meshgrid(x,y);
a = fit([xmesh(:),ymesh(:)],z(:),'poly23');
figure,surf(xmesh,ymesh,z),shading interp
hold on
plot3(xmesh(:),ymesh(:), a([xmesh(:),ymesh(:)]),'*' )