이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Problem doing plots using contour with NaN elements in a matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
Ricardo Duarte
2021년 2월 15일
Dear all,
I have 3 matrices: lon, lat, depth.
Than I want to remove all the depth values that are bigger than 0. To do so I use:
depth(depth>1)=NaN.
By doing this I remove the land part, which is ok.
The problem then is that I want to create a contour arround the sea level, which means at the depth =0. To do so I'm doing:
[C,H]=contour(lon,lat,depth',[0 0]);
As a result I obtain an empty C matrix and I don't understand why!!!
Hope you can help me!
Thanks in advance.
댓글 수: 16
dpb
2021년 2월 15일
That would appear to indicate your resulting data don't have any zero values...not sure anybody here could do anything w/o the Z data.
Ricardo Duarte
2021년 2월 15일
편집: dpb
2021년 2월 15일
The thing is:
If I do
[C,H]=contour(lon,lat,depth', [0 0])
before the depth(depth>1)=NaN it gives me a very nice contour plot. However, if I do it after the C matrix is empty.
I attached my matrices.
Thank you in advance.
dpb
2021년 2월 15일
So, what is it you are trying to do here, anyways? Why are you setting to NaN, anyway?
What's wrong with the returned contour for level==0 from the original array?
Ricardo Duarte
2021년 2월 15일
I want to remove land from my data in order to perform further calculations where the land should not be present.
What I want is to obtain a [C H], where the C is a matrix that has the information about the area selected and that will be used to perform later a delauny triangulation.
Ricardo Duarte
2021년 2월 16일
Yes I understand that, but supposedly the NaN are assigned to levels highers than 1 and not 0.
dpb
2021년 2월 16일
Yes, but there isn't necessarily a crossing with a value between 0 and 1 everywhere for contour to be able to find a closed path.
Again, you want the best estimate of what the zero-level contour is; you don't need to remove data to do that; in fact, you've demonstrated that doing so prevents you from finding that contour level.
Ricardo Duarte
2021년 2월 16일
The problem is that if I don't remove it, when I perform the delauny triangulation it will take into account also the land and I don't want that. I just want triangles on the water and not on land.
dpb
2021년 2월 16일
편집: dpb
2021년 2월 16일
Find the contour first, THEN triangulate. If you have to remove the positions that are >0 then, so be it, but still the countour locations will have been determined and returned in the countour object.
Again, the countour is a boundary; you've got to have something that can be interpolated across the zero plane for countour() to be able to figure out where that is. When you have something that is like [-1.234 NaN] in one direction; what's it supposed to do? There simply is no way to infer where zero is between those two values.
As is, you're not removing all land, anyways, by using the >1 level; you probably will be better served to leave completely alone and find the zero contour object, then remove everything above 0.
I'm not sure what you're doing with the contour object, anyhows???
I've never messed with the guts of contour much other than recollect digging into the convoluted storage pattern of the returned contour object array for somebody here once upon a time to help them retrieve information from it, but having done is all that I do remember.
Ricardo Duarte
2021년 2월 16일
Ok, thank you very much for your help and time invested in this problem. :)
dpb
2021년 2월 16일
What are you trying to triangulate over? How do you try to combine the returned contour path with the remainder of the image that doesn't have anything excepting the elevations in it?
It's just not clear what your next step you're trying to do is -- I'm sure there's a way forward, just need more input on what your end objective really is here.
Doesn't help I don't have any of the mapping toolsets, sorry...
Ricardo Duarte
2021년 2월 16일
Ok, I will try to explain the complete problem.
I have the lon, lat, depth. With that I want to calculate the transmission loss (just at the sea) of a certain region represented by my lon, lat, depth matrices. To do so I need to define the sea level (depth=0) and remove land in order obtain my X and Y vectors and after performe the delauny triangulation. The problem here is that ,if I do not remove land before the contour, when I obtain the C matrix returned by contour, it will triangulate also in the land part and later (in the remaining part of my code) the TL will be calculated also in the land part, which is not correct.
So the code I have is:
[C,H]=contour(lon,lat,depth', [0 0]); I will use C to assing X and Y (at this stage I want to have just sea information)
X=C(1,:); Y=C(2,:);
Then I use the delauny doing this:
tri=delaunay(X,Y); (if I have land, the triangulation will be performed also in the land, which is what I don't want)
and then triplot(tri,X,Y);
And then the rest of the program...
dpb
2021년 2월 16일
편집: dpb
2021년 2월 17일
You have to determine from the contour what is inside and what is outside the sea/land boundary. Removing values >0 from the depth matrix doesn't affect that; in fact by removing those you'll just make estimates of where those are less precise than will be otherwise.
I don't think the basic MATLAB delaunay function knows about how to handle holes automagically and I've not used it enough to know just how one would go about representing the connection points to do this. The routines are for convex polygons.
There is one example of setting constraints for a nonconvex polygon, but even it doesn't actually have a hole in the middle of it; it is roughly a J-shaped polygon.
All in all, I'm not so sure MATLAB is equipped to handle the problem...then again, I didn't DAGS for other examples, either.
dpb
2021년 2월 16일
A search uncovered a response from Bruno that pointed another user to <mesh2d-delaunay-based-unstructured-mesh-generation> on File Exchange
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)