Please help with contour issue
3 views (last 30 days)
Show older comments
Patrick O'Brien
on 6 Feb 2016
Commented: Star Strider
on 7 Feb 2016
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!
0 Comments
Accepted Answer
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
More Answers (0)
See Also
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!