Extrapolating one contour level
Show older comments
I'm having difficulty with my z = 0 contour level.
%x is 1 x 30
%y is 1 x 41
%z is gridded elevation data
[xx,yy] = meshgrid(x,y)
zz=griddata(x,y,z,xx,yy);
a= contour3(xx,yy,zz,0:-3:-18);
I'm taking the contours from the different levels in the contour3 outputs (shown above: 0,-3, -6, ..., -18) and then processing that. My issue is that the contour at z = 0 is very incomplete and I only have discrete patches of data (in other words, there are too few vertices at this level), which won't work for me.
I've tried nearest neighbor with griddata, that doesn't help fill out the z = 0 contour.
It's absolutely a contour level that I need to be continuous.
Is there a way to extrapolate that level so I have have the whole contour without discrete interruptions?
10 Comments
KSSV
on 10 Oct 2020
What is size of xx and yy? Your original data is 30*41 size...so out of it how many zeros are there in z..? By extrploating you cannot trust the data with reality.
Bjorn Gustavsson
on 10 Oct 2020
Have you had a look at your data (for example with trisurf) and verified that this is a sensible idea?
Wthee
on 11 Oct 2020
Bjorn Gustavsson
on 11 Oct 2020
To me that sounds like someone saying something like this "no I want to drive blindfolded and then see the outcome".
Maybe the zero-level is especially complex with a number of comparatively small regions where the triangulated surface intersect z == 0, then the contours might become very small and dominated by sharp corners. You might get a better outcome if you use larger number of points in your xx and yy grids, you might get better-looking contours if you try a smoother interpolation-method ('natural', 'cubic' or 'v4'), you might get better outcomes with the newer functions for interpolation from scattered data: TriScatteredInterp, or scatteredInterpolant, you dont even need to go the route over interpolation to a plaid grid, there are a couple of contour-functions for scattered data on the file exchange. I've used: tricontour with good success.
My advice would be to try tricontour first, because that would be the most direct representation of your data, then you'll see what it looks like and can possibly adapt your approach with better insights.
HTH
Bjorn Gustavsson
on 12 Oct 2020
OK, Now it seems as if your input data z actually barely reaches zero? Have you had a look at your data with for example scatter? Try:
scatter(x,y,23,z,'filled')
Then check the simplest thing:
subplot(2,1,1)
plot(x,z,'.')
subplot(2,1,2)
plot(y,z,'.')
Wthee
on 12 Oct 2020
Bjorn Gustavsson
on 12 Oct 2020
So to the resolution of your plots there seems to be no data with z < 0. If that's the case you will most likely never get any sensible 0-level contour from the triangulation. Try instead for a contour-line at some small positive value, lets say 0.1, 0.2. That might be the lowest level for which you might get a sensible contour-line.
Wthee
on 12 Oct 2020
Answers (0)
Categories
Find more on Surface and Mesh 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!