Surface plot from 3d scatter of a filled object

12 ビュー (過去 30 日間)
Eric Ledieu
Eric Ledieu 2022 年 5 月 20 日
回答済み: Moksh 2023 年 11 月 7 日
I have a data set that is a bunch of 3d coordinates. I have to reconstruct a 3d surface from it. I would use mesh or contour, but my points are not IN the surface, but rather some are in, while some are above. all I know is I have no points below that surface.
I tried the following code snippet and similar ones, and while it does get close, it has issues where the points are dense (I have a lot) because it tries to make a surface that hits every point.
! list XYZ are the scatter points
Xq = linspace(min(listX),max(listX),1000); ! I tried reducing the resolution here, and it helped a little,
Yq = linspace(min(listY),max(listY),1000); ! but it did not resolve the issue.
[X,Y] = meshgrid(Xq,Yq);
F1 = scatteredInterpolant(listX(:),listY(:),listZ(:),"natural","none");
Z = F1(X,Y);
! I don't really know how to approach the problem, from a math standpoint. any hint or jumping off point would be much appreciated.
  2 件のコメント
Monica Roberts
Monica Roberts 2022 年 5 月 20 日
Sounds like you need the curve fitting toolbox, try "cftool" (or "curveFitter" in R2022a). If you don't have the curve fitting toolbox, I'd suggest a trial.
Eric Ledieu
Eric Ledieu 2022 年 5 月 20 日
thank you for the suggestion! I am trying the different fits. I'll put up the answer if I find it.

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

回答 (1 件)

Moksh
Moksh 2023 年 11 月 7 日
Hi Eric,
I understand that you want to generate a 3d surface from a set of 3d coordinates with some of them being outside and inside the surface.
You can try using the “fit” function in the “Curve Fitting Toolbox” in MATLAB which creates a surface fit to the input data. You can specify the type of fit in the function along with the data provided according to the requirements.
Here is an example code for using this function:
% Generate random 3D coordinates
numPoints = 1000;
x = rand(numPoints, 1) * 10;
y = rand(numPoints, 1) * 10;
z = rand(numPoints, 1) * 10;
% Fit a surface to the random data
sf = fit([x, y], z, 'poly23');
% Plot the surface
plot(sf);
For more information about the “fit” function and which type of fit to use please refer to the following documentation:
Hope this information helps resolve the query
Best Regards,
Moksh Aggarwal

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by