MATLAB: Plot data X,y,z data as surface

surf imagesc

Hi all.
I am trying to plot stress values with matlab. My file dataset is with 3 columns: x_coord, y_coord, stress (which correspond to the stress values).
I tried to use scatter but, obviously, it plot the data as a point which is not exactly what I want.
I used scatterinterpolant+surf and imagesc but the colorbar numbers are different from the real data, so I am not sure I am doing the right thing.
F = scatteredInterpolant(x_axis, y_axis,zvalue);
min_x_axis = min(x_axis);
min_y_axis = min(y_axis);
max_x_axis = max(x_axis);
max_y_axis = max(y_axis);
x= linspace(min_x_axis, max_x_axis, 100);
y = linspace(min_y_axis, max_y_axis, 100);
[X, Y] = ndgrid(x, y);
D = F(X, Y);
surf(X, Y, D, 'edgecolor', 'none');
Thanks to all who can help me.

Best Answer

Your code looks good. How exact are you expecting the colorbar to be? You've interpolated the data, so it's not going to exactly match.