How to find when a surface deviates from other surface(s)

조회 수: 1 (최근 30일)
A
A 2014년 4월 18일
댓글: Star Strider 2014년 4월 19일
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

답변 (1개)

Star Strider
Star Strider 2014년 4월 18일
편집: Star Strider 2014년 4월 18일
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
A
A 2014년 4월 19일
So would there be a way to ask MatLab to please print or give [x,y] wherever OfInterest = 1?
Sorry I don't know enough Matlab code to do this. If this was Java, I'd say something like:
if(OfInterest = 1) { system.printout([x,y]); }
lol.
Star Strider
Star Strider 2014년 4월 19일
Probably the easiest way is to use the find function:
[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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by