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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by