
clear
clf

s=peaks;
s=s.*s;
s=s/max(max(s));

xlabel(' x ')
ylabel(' y ')
zlabel(' p(x,y) ')
[nx ny]=size(s);

x=1:nx;
y=1:ny;

sx=sum(s);
sy=sum(s');

sx=sx/max(sx);
sy=sy/max(sy);

surf(s),shading interp, 
xlabel(' x ')
ylabel(' y ')
zlabel(' p(x,y) ')
axis([ 0 50 0 50 0 1]);

hold on

plot3(x,y*0+50,sx,'r-','LineWidth',3)
plot3(x*0+50,y,sy,'r-','LineWidth',3)