MATLAB: Symmetric color map using surf

colour codeMATLAB and Simulink Student Suitesurf

Hi there,
I would like to show in a graph a symmetric color driving from 0 green to either + and – to red. The peak at the bottom should be in colour yellow again.
All areas around 0 in green. Anyone an Idea? Cheers
AddColorbarToGraphExample_01.png

Best Answer

Like this?
cmap = interp1([-1;0;1],[1 0 0;0 1 0;1 0 0],linspace(-1,1)');
surf(peaks)
colormap(cmap)
colorbar
surf.png