Whiteout/Remove some part of the contour plot

16 ビュー (過去 30 日間)
Muhammad Usman
Muhammad Usman 2019 年 11 月 6 日
編集済み: Muhammad Usman 2020 年 4 月 13 日
I use the built-in MATLAB function "scatterInterpolant" to plot a contour. The plot is shown below.
It's s stress contour and the ellipse is an empty space and there are no nodes inside the ellipse. I want the ellipse to be whiteout. Somehow I managed to set the values inside the ellipse to be zero (because I can't delete them) and I got the following result
I want the ellipse to be whiteout. Any sort of help is highly appreciated. Thanks in advance.
P.S. I use the fill command to fill the ellipse with white color but that's not a proper way to do it.

採用された回答

Robert U
Robert U 2019 年 11 月 7 日
Hi Muhammad Usman,
instead of assigning Zero to the nodes you don't want to use, apply "nan"-Values. That will be treated as if there is no value assigned and will be plotted with white color.
x = -100:100;
y = -100:100;
inputData = rand(201);
inputData(abs(x)<=10,abs(y)<=10) = nan;
contourf(x,y,inputData,'LineStyle','none');
contourfPlot.png
Kind regards,
Robert
  1 件のコメント
darova
darova 2019 年 11 月 7 日
I like that solution. It works

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

その他の回答 (1 件)

Muhammad Usman
Muhammad Usman 2019 年 11 月 7 日
Thank you very much sir for your kind response, but there is another problem I am encountering. As you can see in the figure below that it also whiteout some of the nodes outside the ellipse.
xyz.jpg
What do you think about that?
  8 件のコメント
Tamas Lanci
Tamas Lanci 2020 年 4 月 3 日
Is there any chance you can share your code Muhammad?
Muhammad Usman
Muhammad Usman 2020 年 4 月 13 日
編集済み: Muhammad Usman 2020 年 4 月 13 日
F = scatteredInterpolant(xgrid, ygrid, plotcomp, 'nearest') ;
% plotcomp contains the values of stress etc at xgrid and ygrid i.e. mesh
[X,Y] = meshgrid(); % creat equally spaced rectangular mesh
Z = F(X,Y);
% then access the nodes of [X,Y] mesh grid which are inside the hole\ellipse
Z( " nodes inside the hole " ) = nan ;

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

カテゴリ

Help Center および File ExchangeGeometry and Mesh についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by