Comparing Two Matrices and Returning Differences...

6 visualizaciones (últimos 30 días)
Michelle De Luna
Michelle De Luna el 17 de Abr. de 2020
Comentada: Michelle De Luna el 17 de Abr. de 2020
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 comentario
David Hill
David Hill el 17 de Abr. de 2020
An example of your data would be helpful. What have your tried?

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 17 de Abr. de 2020
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.

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by