is there any way to check if any point exactly overlaps with another point?
조회 수: 4 (최근 30일)
이전 댓글 표시
I basically have data in many files.i.e latitude longitude and temperature. Now when a new file comes in i want to be able to check if any record has the same latitude and longitude combination and if it does i want to ignore it.I know it can be done through a program but i think it will take a very long time to check this for every particular record and may take around O(n^2).Is there any other way to do this???
댓글 수: 0
답변 (1개)
Walter Roberson
2013년 2월 15일
How are the latitude and longitude represented? If they are floating point numbers, then you will have a problem. See http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
If you use a binary search, then you can determine match or not in log2(n) time, and so can do all of the checks in at most O(n*log(n)) time. O(log(n!)) time really. Excluding the cost of the insertions (which would be at the point the match was determined not to exist.)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!