Problem obtaining a symmetrical surface using surf

%% Dear matlab user, probably my question is simple but...
%% I would like to plot z=f(x,y) using "surf" with the code below.
%%% In my datas, maximum value (50) of z is at x=y=0 but not in the surface plot.
%%% how can I have the center of the red square at x=y=0 and not at x=y=0.5
%%% thank you.
%%%% denis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure (1)
clf
x=[ -3 -2 -1 0 1 2 3 ];
y=[ -2 -1 0 1 2];
z=[
0 0 0 0 0 0 0
0 0 30 30 30 0 0
0 0 30 50 30 0 0
0 0 30 30 30 0 0
0 0 0 0 0 0 0];
surf (x,y,z)
view([0 90])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 Accepted Answer

You cannot. surf() always uses the interior intersections of the original data as the locations of its vertices, and it can only assign colors at those locations; see the CData property at http://www.mathworks.com/help/matlab/ref/surfaceplotproperties.html
If you want to look down from above like that, use imagesc() instead of surf()

More Answers (0)

Products

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!