Surface plot from 3d scatter of a filled object
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Monica Roberts
am 20 Mai 2022
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.
Antworten (1)
Moksh
am 7 Nov. 2023
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:
- "fit" - https://www.mathworks.com/help/curvefit/fit.html
- "types" - https://www.mathworks.com/help/curvefit/list-of-library-models-for-curve-and-surface-fitting.html
Hope this information helps resolve the query
Best Regards,
Moksh Aggarwal
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!