Compare two meshes for difference in values
Show older comments
I feel like I should know how to do this, but apparently I don't have the patience to figure it out today.
I have two 'mesh grids' with assigned values in mx4 and nx4 arrays. I would like to compare the result values, column 4, for points which have the same coordinate values, columns 1:3. I can identify the coordinates of the points which are the same using intersect, but my attempts at getting the difference in result values through logic indexing have been unsuccessful.
data = struct('name',{'Original','Layered'});
[data(1).nums] = randi(100,100,4);
[data(2).nums] = randi(100,200,4);
rs = intersect(data(1).nums(:,1:3),data(2).nums(:,1:3),'rows');
compared = [rs,find(data(1).nums(data(1).nums(:,1:3)==rs,4))-find(data(2).nums(data(2).nums(:,1:3)==rs,4))];
Error: Matrix dimensions must agree.
I don't care that much about fixing this error specifically, if somebody knows a better way to do the comparison, this was just where my train of thought went.
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!