Comparing Two Matrices and Returning Differences...

6 次查看(过去 30 天)
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 个)

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 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by