フィルターのクリア

Why my grid data always show a zero by zero dimension?

2 ビュー (過去 30 日間)
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim 2022 年 3 月 21 日
編集済み: DGM 2023 年 11 月 26 日
I want to plot contourf and for that I need to create grid data but it always shows a zero by zero dimesion.
Lat=1:1:100;
Long=201:1:300;
Elv=151:1:250
[xg yg] = meshgrid(Lat,Long);
zg = griddata(Lat,Long,Elv,xg,yg);
contourf(xg,yg,zg);
  1 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2022 年 3 月 21 日
This looks like you have Elv-data along a line in Lat-Long and then tries to extrapolate the Elv (elevation?) out into a rectangular Lat-Long regio. Since griddata works with a Delaunay-triangulation (unless you specify the 'v4' method that is slightly different in a way that doesn't help you here) it requires at least one point to be off of that line to be able to produce any triangles, and these triangulations work best for interpolation inside the sensible convex boundary of the Lat-Long-points, while peculiar things often happen when one tries to extrapolate. This gives us another way to look at why you run into problems - you dont really have much of a convex hull to your points when they are co-linear.
In this situation you might just as well simply assume that your points lie on a plane with the normal in the Lat-Long-points-and-vertical plane but perpendicular to that elevation-line?

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

回答 (1 件)

Ishu
Ishu 2023 年 11 月 26 日
Hi Muhammad Qaisar Fahim,
I understand that you are trying to interpolate the data onto a grid using "griddata" but you are getting "zg" as empty.
If you try to run this code upto "zg" you will get a warning that "The underlying triangulation is empty - the points may be collinear". It is just that your input data is collinear that is why "griddata" is not able to interpolate the data, as a result you are getting "zg" as empty.
You can try by changing your "Lat" and "Long" data like I have shown below.
Lat=1:0.3:30.8;
Long=201:1.5:350;
Elv=151:1:250;
[xg, yg] = meshgrid(Lat,Long);
zg = griddata(Lat,Long,Elv,xg,yg)
zg = 100×100
151 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 152 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 153 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 154 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 155 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 156 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 157 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 158 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 159 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 160 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
For more information you can read below MathWorks documentation:
Hope it helps.
  1 件のコメント
DGM
DGM 2023 年 11 月 26 日
編集済み: DGM 2023 年 11 月 26 日
How is this an answer to the question?
You've presupposed different data. That's not generally an option.
The sample locations are still colinear. The only thing that this particular data selection does is introduce small rounding error that causes the points to not be treated as colinear even though they still are nominally colinear. It would be less presumptuous to merely add a tiny amount of gaussian noise to the original data instead of conjuring up entirely new unrelated data.
Either way, the result is still useless for the intended purpose. It's still just a vector. Elv is now merely diag(zg). That's it. No triangulation or interpolation or extrapolation has occurred. It's still degenerate. It's still a surface of zero area. There still is no point feeding it to contour(), because there's nothing to show.

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

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by