Extrapolating one contour level

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 件のコメント

KSSV
KSSV 2020 年 10 月 10 日
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.
Wthee
Wthee 2020 年 10 月 10 日
編集済み: Wthee 2020 年 10 月 11 日
xx and yy are 201 x 146. It seems that linear triangulation was working well enough in the other contours. Hoping that it would help, I have set contour3 to create more contours, but then I get more discrete sections.
I'm just trying to figure out a method.
Bjorn Gustavsson
Bjorn Gustavsson 2020 年 10 月 10 日
Have you had a look at your data (for example with trisurf) and verified that this is a sensible idea?
Wthee
Wthee 2020 年 10 月 11 日
No... I want to extrap then see
Bjorn Gustavsson
Bjorn Gustavsson 2020 年 10 月 11 日
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
Wthee
Wthee 2020 年 10 月 12 日
編集済み: Wthee 2020 年 10 月 12 日
I did increase the spacing in my xx and yy grids beforehand, using griddata interp, it didn't seem to have much effect, perhaps a bit smoother.
tricontour is a mess with the patches, it doesn't seem to give an output accurately like contour3, and it doesn't ignore Nan. not sure how to organize the C output. This does look promising though.
scatteredInterpolant didn't seem to improve results, tried that this morning.
triscatt... doesn't seem to work with gridded data
edit: actually I'm not sure tricontour is better
Bjorn Gustavsson
Bjorn Gustavsson 2020 年 10 月 12 日
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
Wthee 2020 年 10 月 12 日
Ok, took a second to convert back from gridded.
It looks like the x-y plot is much more sparsely populated near z=0 than the y-z graph. How does this help?
Bjorn Gustavsson
Bjorn Gustavsson 2020 年 10 月 12 日
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
Wthee 2020 年 10 月 12 日
The fit tool works like a marvel, under the curve fitting toolbox.
Thanks for you help!

サインインしてコメントする。

回答 (0 件)

カテゴリ

製品

リリース

R2020a

質問済み:

2020 年 10 月 10 日

コメント済み:

2020 年 10 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by