Smooth out a surf plot

I have created a surface plot of temperature data I have, all the x,y coordinates are integer values. I simply made a variable with my temperatures and used the surf command. This is what I have:
However that is way too 'chunky' for me to use. I need to prepare this for a presentation and I would like the graph to look more like this:
The second image is just one I grabbed off of google but that is what I am looking for.
Is there any way to generate an image like the second one from my data in MatLab? Or is there a way to make the image I already have into one like the second one using some imaging software?
Accuracy is important but it is secondary to appearance here. I really feel like this should be possible but if I'm asking for the moon here let me know, I have very little experience with MatLab. Thanks for any help!

1 Comment

David
David on 30 Jun 2025
Edited: David on 30 Jun 2025
This is what I have:
However that is way too 'chunky' for me to use. I need to prepare this for a presentation and I would like the graph to look more like this:
You’re definitely not asking for the moon—this is totally doable in MATLAB! Try using interp2 to increase the resolution of your data grid before using surf, or switch to mesh with interpolated shading for a smoother look. Also, add shading interp to your plot—it’ll blend the colors and remove the “chunky” block effect. Should get you much closer to that second image!

Sign in to comment.

 Accepted Answer

Yes that's not difficult at all! Use interp2 to interpolate your surface to a finer grid.
doc interp2
Addendum
X = bsxfun(@(x,y)hypot((x-5),(y-5)),1:10,(1:10).'); %sample
subplot(121);
surf(X);
subplot(122);
[xx yy] = meshgrid(1:0.1:10); %force it to interpolate at every 10th pixel
surf(interp2(X,xx,yy))
grid off %turn off grid

4 Comments

Aaron
Aaron on 29 Jun 2011
Much better, now I have:
I just did:
V=interp2(datamatrix);
W=interp2(V);
...surf(Z)
If there is a better way to use this let me know but this is a big improvement, thank you.
I used set(H,'linestyle','none')
to remove the mesh lines on top of the surface but now I feel like it is hard to 'see' the 3d aspect.
http://i1115.photobucket.com/albums/k545/RedK24/untitled2.jpg
Is there a way to keep some of the grid lines but not all of them so that I don't end up with a black image?
You could try using mesh. As there become more data points, mesh plots tend to be better.
Aaron
Aaron on 29 Jun 2011
Thanks again, I've got everything worked out and I am satisfied with my result.
http://i1115.photobucket.com/albums/k545/RedK24/9-97surfaceplot.jpg
This was really helpful, but I'm having trouble implementing it in an animated surf plot.
Should it go outside the 'for' loop (it's a 10 x 10 matrix of audio measurements with amplitude/time on z-axis) when I explicity create the figure, or does the interpolation need to be done with each new matrix of data drawn from measurement poisitions with each plot frame, that is, "in" the 'for' loop.
Thanks.

Sign in to comment.

More Answers (0)

Asked:

on 29 Jun 2011

Edited:

on 30 Jun 2025

Community Treasure Hunt

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

Start Hunting!