How to find when a surface deviates from other surface(s)
1 view (last 30 days)
Show older comments
Hi guys,
I have 3 surfaces. I want to find out values for x and y, where each of the three surfaces deviates from the other two by more than 0.5 value on the z axis. Is this a simple enough thing?
I can imagine it being super easy to do with only two surfaces because you could just substract one from the other. But how do I do it with 3 surfaces? Any ideas?
Ideally, I'd like to see [x,y] points for each surface where it deviates from other surfaces on z-axis by > 0.5.
It would be great to be able to graphically see this 'deviation' as well perhaps as another surface?
A member on the forum recommended the following method, however my inexperience with matlab means that I'm not sure how to interpret the logical array and/or see it as a plotted surface.
>> x = [-10:10];
>> y = [-10:10];
>> test1 = x + 0.5*y;
>> test2 = x + y;
>> test3 = x + 1.5*y;
>> testI = meshgrid(test1);
>> testII = meshgrid(test2);
>> testIII = meshgrid(test3);
>> surf(x,y,testI);
>> hold on
>> surf(x,y,testII);
>> surf(x,y,testIII);
*>> OfInterest = any(diff( sort( cat(3, test1, test2, test3), 3), 3) > 0.5, 3);*
>> OfInterest
OfInterest =
Columns 1 through 15
0 0 0 0 0 0 0 0 1 1 0 0 0 0 0
Columns 16 through 18
0 0 0
>> image(OfInterest);
>> colormap(gray(2));
Thanks
0 Comments
Answers (1)
Star Strider
on 18 Apr 2014
Edited: Star Strider
on 18 Apr 2014
Does this do what you want?
x = -10:10;
[X,Y] = meshgrid(x);
test1 = X + 0.5.*Y;
test2 = X + Y;
test3 = X + 1.5.*Y;
figure(1)
surfc(X,Y,test1)
hold on
surf(X,Y,test2)
surf(X,Y,test3)
hold off
% ‘OfInterest’ -> Walter Roberson (http://www.mathworks.com/matlabcentral/answers/125901-how-to-find-when-a-surface-deviates-from-other-surface-s)
OfInterest = any(diff( sort( cat(3, test1, test2, test3), 3), 3) > 0.5, 3);
D = zeros(size(X));
D(1:size(OfInterest,1), 1:size(OfInterest,2)) = OfInterest(1:end,1:end);
figure(2)
surfc(X, Y, D)
12 Comments
Star Strider
on 19 Apr 2014
[r,c] = find(OfInterest == 1);
This will give you the row- and column-indices of the elements of OfInterest that are equal to 1. You can then use them to identify the corresponding values of X and Y.
See Also
Categories
Find more on Surface and Mesh Plots 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!