フィルターのクリア

How to ignore specific parts of a plot ??

7 ビュー (過去 30 日間)
Ceren GURKAN
Ceren GURKAN 2014 年 6 月 17 日
コメント済み: Jason Nicholson 2014 年 6 月 18 日
Hello everybody,
I have the attached plot, the circles and the ellipse are holes so in my plot I want to leave blank inside the circles and the ellipse I do not want the lines cut through those.
Any suggestions how to do that??
  2 件のコメント
dpb
dpb 2014 年 6 月 17 日
How were they created? Is there data inside the boundaries; if so turn it to NaN and see if that's enough of a clue to the handle graphics to not display those locations.
Ceren GURKAN
Ceren GURKAN 2014 年 6 月 17 日
Here how they are created:
if true
x = linspace(min(X_plot(:,1)), max(X_plot(:,1)), 100);
y = linspace(min(X_plot(:,2)), max(X_plot(:,2)), 100);
[xg, yg] = meshgrid(x, y);
Fx = TriScatteredInterp(X_plot(:,1), X_plot(:,2), qx);
Fy = TriScatteredInterp(X_plot(:,1), X_plot(:,2), qy);
qxg = Fx(xg,yg);
qyg = Fy(xg,yg);
figure(1); hold on;
hl = streamslice(xg, yg, qxg, qyg);
set(hl, 'color', 'b','Linewidth',0.5);
end
It is actually quite tricky to remove the data corresponding to those holes this is why I am looking for another solution.

サインインしてコメントする。

採用された回答

Jason Nicholson
Jason Nicholson 2014 年 6 月 17 日
Given the mesh I see in your picture, the following works becuase your elements are not distorted and your edges are very close to linear:
xg = linspace(min(X(:,1)), max(X(:,1)), 100);
yg = linspace(min(X(:,2)), max(X(:,2)), 100);
[xg, yg] = ndgrid(xg, yg);
elementNumber = tsearchn(X, T(:,1:3), [xg, yg]);
nans = isnan(elementNumber);
Fx = TriScatteredInterp(X_plot(:,1), X_plot(:,2), qx);
Fy = TriScatteredInterp(X_plot(:,1), X_plot(:,2), qy);
qxg = Fx(xg, yg);
qyg = Fy(xg, yg);
qxg(nans) = NaN;
qyg(nans) = NaN;
figure(1); hold on;
hl = streamslice(xg, yg, qxg, qyg);
set(hl, 'color', 'b','Linewidth',0.5);
  4 件のコメント
Ceren GURKAN
Ceren GURKAN 2014 年 6 月 18 日
Jason, not exactly what you wrote but the following does me a bit better:
if true
x = linspace(min(X(:,1)), max(X(:,1)), 100);
y = linspace(min(X(:,2)), max(X(:,2)), 100);
xi=[x;y]';
elementNumber = tsearchn(X, T(:,1:3), xi);
[xg, yg] = meshgrid(x,y);
nans = isnan(elementNumber);
Fx = TriScatteredInterp(X(:,1), X(:,2), qnewx);
Fy = TriScatteredInterp(X(:,1), X(:,2), qnewy);
qxg = Fx(xg, yg);
qyg = Fy(xg, yg);
qxg(nans) = NaN;
qyg(nans) = NaN;
figure
hl = streamslice(xg, yg, qxg, qyg);
set(hl, 'color', 'b','Linewidth',0.5);
end
How it looks is the following :
Thanks a lot.
Jason Nicholson
Jason Nicholson 2014 年 6 月 18 日
I can look at more tonight. Can you post the qx and qy vectors so that I can look closer at the problem?

サインインしてコメントする。

その他の回答 (1 件)

Jason Nicholson
Jason Nicholson 2014 年 6 月 17 日
編集済み: Jason Nicholson 2014 年 6 月 17 日
Can you post the data that made this plot?
My hunch is the main issue is TriScatteredInterp used Delaunay triangulation of your data and the holes were meshed in the TriScatteredInterp function. If instead you used the original triangulation to do the interpolation, then you should be able to get the desired result. If you can post the mesh, I can post code that does the interpolation without TriScatteredInterp. My code would rely on tsearchn to locate the element that contains point [xg, yg] and then use the local barycentric coordinates to interpolate. The key though is to use your mesh to define connectivity of your points. Points [xg, yg] that are not contained in an element will be returned as nan's and thus will not show up on the plot. So something like this:
[elementNumber, localElementCordinates] = tsearchn(xyCordinates, myTriangulation, [xg, yg]);
notNan = ~isnan(elementNumber);
qxg = nan(size(xg,1), 1);
qyg = nan(size(yg,1), 1);
% connectivity of elements containing points
elementsContainingPoints = myTriangulation(notNan,:);
% weights of nodes for given uq points that are contained in elements
weights = localElementCordinates(notNan,:)
qxg(notNan) = sum(weights.*qx(elementsContainingPoints),2);
qyg(notNan) = sum(weights.*qy(elementsContainingPoints),2);
  3 件のコメント
Jason Nicholson
Jason Nicholson 2014 年 6 月 17 日
編集済み: Jason Nicholson 2014 年 6 月 17 日
Okay so may answer may not work because your mesh has 6 node parabolic triangles rather than 3 node linear triangles.
Really you need a set of tools for parabolic triangles: locate an element containing a given point barycentric coordinates (local weighted coordinates of the nodes).
Do understand what TriScatteredInterp is doing when you use natural neighbor interpolation?
I'll have to think about this a little more.
Jason Nicholson
Jason Nicholson 2014 年 6 月 17 日
How are you generating your mesh?

サインインしてコメントする。

カテゴリ

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