Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim el 21 de Mzo. de 2022
Editada: DGM el 26 de Nov. de 2023
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 comentario
Bjorn Gustavsson
Bjorn Gustavsson el 21 de Mzo. de 2022
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?

Iniciar sesión para comentar.

Respuestas (1)

Ishu
Ishu el 26 de Nov. de 2023
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 comentario
DGM
DGM el 26 de Nov. de 2023
Editada: DGM el 26 de Nov. de 2023
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by