MATLAB: SURF plot: Data dimensions must agree

3d plotserrorplotplottingsurf

I am trying to plot the magnetic field on a rectangular surface (having x and y coordinates). Hence i have a total of 3 values x,y and B (magnetic field). I have tried plotting the surface plot using normal and transposed datasheet in excel but both of them give me the same data dimensions error. Please help me withi this. I am using the following code till now:
dataset=xlsread('import.xlsx');
x = dataset(:,1);
y = dataset(1,:)
Z = dataset(2:end,2:end)
surf(x,y,Z)
Please see the attached image for clarification.
thank you

Best Answer

dataset=xlsread('import.xlsx');
x = dataset(2:end,1);
y = dataset(1,2:end);
Z = dataset(2:end,2:end);
surf(x, y, Z.', 'edgecolor', 'none')
Related Question