MATLAB : Get smoothly coloured outputs when using surf / trisurf

I had been struggling since sometime to get smoothly textured outputs using surf / trisurf commands in MATLAB. The edges of the locally planar element being used by the respective commands used to always “stand out” with respect to the texture of the contained patch.  Only today i found out a simple 1 line command that solves this problem..

tri = delaunay(X,Y);


shading interp;                   % other options are shading face / shading faceted

And you are done.. you can check for yourself the extent to which this 1 line of code creates a change in visualization of 3d textured data.

Sample outputs, before and after :

surf output BEFORE

surf output AFTER