Comparing Two Matrices and Returning Differences...

4 ビュー (過去 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.
  1 件のコメント
Michelle De Luna
Michelle De Luna 2020 年 4 月 17 日
Thank you very much! I appreciate the help. :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by