How do I make surface plots with many NaN's in my matrix?

68 views (last 30 days)
So I have a matrix of data that I'm trying to plot on the z-axis of a surface plot. However, it is populated with NaN's where I do not want data points to be plotted. This results in surface plots that look like this:
MATLABerror.jpg
It looks like a surface should fit over those points, but surf is having a hard time filling in the areas with color. I'm doing
surf(p1,q1,F1,'EdgeColor','interp','FaceColor','interp')
where F1 is my matrix with NaN's. Any ideas on how to make this work?

Accepted Answer

Star Strider
Star Strider on 13 Mar 2019
The fillmissing (link) function may be what you want. See specifically Matrix with Missing Endpoints (link).
  2 Comments
Alex Foster
Alex Foster on 13 Mar 2019
I hadn't thought about just interpolating for the NaN's this way, but it works out pretty great. Thanks!

Sign in to comment.

More Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!