フィルターのクリア

Trying to plot surface using "surfir" - but getting the wrong boundary (due to interpolation error)

1 回表示 (過去 30 日間)
Oliver Bond
Oliver Bond 2023 年 2 月 8 日
編集済み: Stephen23 2023 年 2 月 8 日
I am trying to take the output of a solution to a problem in COMSOL, and construct a smooth surface using the (x,y,z) values. I have come across the very helpful function surfir, which very nearly does exactly what I want.
I have written my own function called mphplot2surf as below, which uses LiveLink with COMSOL to load a model (called "model") in MATLAB and examine the data produced, referring to a plot group known as "pg".
function out = mphplot2surf(model,pg)
comsolPlot = mphplot(model,pg)
xCoords = double((comsolPlot{2}{1}.p(1,:))');
yCoords = double((comsolPlot{2}{1}.p(2,:))');
zCoords = double(comsolPlot{2}{1});
surfir(xCoords,yCoords,zCoords,0.2)
end
and with a particular model and plot group in mind, I get the following plot, where I have added some black lines to indicate where the true boundary of the domain is. It is a T-shaped domain, but MATLAB has incorrectly interpolated between two points on each side and therefore not correctly identified the true boundary. Since surfir relies on interpolation, I can't simply select points on these triangular portions and delete them.
I am stumped as to how to fix this. Could anybody please assist (even if you haven't used COMSOL before)
  1 件のコメント
Stephen23
Stephen23 2023 年 2 月 8 日
編集済み: Stephen23 2023 年 2 月 8 日
"but MATLAB has incorrectly interpolated between two points on each side and therefore not correctly identified the true boundary."
Actually it is the third-party function SURFIR() that does that. The function SURFIR() relies on
to detect the boundary points, which according to its documentation uses an alpha shape:
The "tightness" of its fit can be controlled by its "shrink factor" input argument (default value = 0.5). But it is the nature of an alpha shape (moving a circle/sphere around the points cloud) that it cannot really fit into a arbitrarily tight corners like your concave right angles. It rather depends on the density of your data points, but I suspect that an alpha shape will not work for you.
Why not just interpolate over the whole rectangle, and then mask the points using NaN when plotting?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by