How to compare values between two NxM matrices
Show older comments
Hello everyone!
I'm still pretty new to MatLab, and am getting familiar with how to operate it, so I am looking for some ideas as to how to best tackle this problem. It seems like a FOR loop to compare the minimums would be the best way to tackle this, but I'm not sure.
I have two matrixes that I need to examine for a discrepancy between expected altitude and measured altitude. I need to compare a matrix of DEM data (1x1920) against a matrix of retrieved altitudes (820x1920). I need to index the columns where there the altitude plots below the DEM, and examine the difference between the two matrices.
The example below provides an outline of the problem. The white line represents recorded DEM data, and the curtain represents the data I need to examine to determine if there was an error with the recorded altitude. For example, the DEM data below, idx(1,563) shows .5767, and the altitude at that same point shows idx(773,563) shows a value of 1.0735. So there is no numerical correlation between the value of the DEM and the value of the altitude (since it seems more akin to a bar graph).
Any help getting started with this would be much appreciated!

4 Comments
Umar
on 18 Jun 2024
To address this issue, you can use Matlab to compare the two matrices and identify the columns where the measured altitude is lower than the DEM data. One approach is to iterate through each column using a FOR loop and compare the values at each corresponding index. Here is a simplified example to get you started:
% Example matrices (replace with your actual data)
DEM_data = rand(1, 1920); % Random DEM data
altitude_data = rand(820, 1920); % Random altitude data
% Find columns where altitude is below DEM
discrepancy_columns = [];
for col = 1:size(altitude_data, 2)
if any(altitude_data(:, col) < DEM_data(col))
discrepancy_columns = [discrepancy_columns, col];
end
end
% Analyze the differences between the matrices for the identified columns for col = discrepancy_columns % Perform further analysis or actions for the columns with discrepancies
disp(['Column ', num2str(col), ' has altitude below DEM']);
end
Umar
on 18 Jun 2024
You can adapt this code snippet to your specific data and further analyze the identified columns to understand the discrepancies between the altitude and DEM data. This should help you get started on tackling the problem efficiently in Matlab.
Christopher
on 18 Jun 2024
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!