필터 지우기
필터 지우기

Comparing Two Matrices and Returning Differences...

조회 수: 7 (최근 30일)
Michelle De Luna
Michelle De Luna 2020년 4월 17일
댓글: Michelle De Luna 2020년 4월 17일
Hi friends!
I hope this post finds you all in good health! I'm reaching out because I had a question regarding the comparison of two matrices with geographic coordinates. I have matrix A (which has latitude, longitude, and frequency) as well as matrix B (which also has latitude, longitude, and frequency). I'm trying to build a third matrix - matrix C - where I have the differences of matrix A and matrix B, i.e. the latitude/longitude/frequency that were in matrix B but did not initally appear in matrix A. However, if there was a value that appeared in both matrix A AND matrix B, but the value of "frequency" was different (e.g. frequency for matrix A was 3 and for matrix B was 7), I would also like to be able to keep the latitude and longitude of this data point, but have the difference in value be represented in the new matrix. Is there anyway to do this for large matrices? Any help would be greatly appreciated. :)
M.
  댓글 수: 1
David Hill
David Hill 2020년 4월 17일
An example of your data would be helpful. What have your tried?

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2020년 4월 17일
Get a combined set of all coordinates:
lat = [A(:, 1); B(:, 1)];
lon = [A(:, 2); B(:, 2)];
xy = unique([lat, lon], 'rows');
latBoth = xy(:, 1);
longBoth = xy(:, 2);
Now use the original lat, lon, and frequencies in scatteredInterpolant() to get the values at the locations that were not present in the one array but were present in the other one by passing in latBoth and longBoth. I'm attaching a scatteredInterpolant demo to help you with that part.
Once you have an array where both A and B have estimates for all locations, you can subtract the arrays to find your frequency differences.

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by