Please help with contour issue

2 views (last 30 days)
I have a data set of x,y,z data that I am trying to create a contour plot from. The data can be displayed in scatter plot just fine, but when i contour plot it, something weird happens in the corner where there were no data points.
Code:
% Create a 100x100 sample mesh grid of the size of the data
[Xgrid, Ygrid]=meshgrid(linspace(min(A(:,1)),max(A(:,1)), 100), linspace(min(A(:,2)),max(A(:,2)), 100));
% Create interpolate class from data
SI=scatteredInterpolant(A(:,1),A(:,2), A(:,3));
% Plot it by grabbing interpolated data from the class at the specific query points
contourf(Xgrid, Ygrid, SI(Xgrid, Ygrid));
Is there a way to stop it from interpolating so strangely in the corner? That whole corner (upper right) should be 1 contour level since there is no data there in the original data set. Instead it looks like a cliff.
Please advise!

Accepted Answer

Star Strider
Star Strider on 6 Feb 2016
You’re asking it to extrapolate, and that is never without problems. The scatteredIntrepolant doesn’t offer many extrapolation options, so I can only suggest you experiment with the two (or three) that are available to see what works best for you. The
SI.ExtrapolationMethod = 'none';
option may work best for you.
  2 Comments
Patrick O'Brien
Patrick O'Brien on 6 Feb 2016
You are a god among men. That response time was amazing! Here is the new map:
While not giving me exactly what I want (a flat plotted surface in the corner), it at least gets rid of the faulty cliff contours from before. Thank you very much.
Star Strider
Star Strider on 7 Feb 2016
My pleasure!
If my Answer solved your problem, please Accept it!

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!