フィルターのクリア

fit questions for surface from 3d scatter plot

8 ビュー (過去 30 日間)
Brent Majcher
Brent Majcher 2022 年 3 月 4 日
編集済み: William Rose 2022 年 3 月 4 日
Hi everyone...
I have a matrix of coordinates [480,000, 3] which has obviously a lot of data. This is a survey of a surface with many coordinates.
I would like to smoothen this surface and keep the accuracy of the data (from a statisitical point of view).
I am trying to use the fit function and my script looks like this:
X = [480000, 3];
sf = fit( [X(:,1),X(:,2)], X(:,3), _____);
I am trying to use the 'lowess' method, since I understand this will use linear local regression which sounds like the right thing for my purposes (some points have an inaccurate Z coordinate and thus averaging out the surface or smoothing it out to be closer to a mean value is desirable). The lowess function 'smoothens' the surface too much, and appears to be modelling the surface over too large a span (I understand the span is set to 0.25 by default).
Is there a simple way to lower the span to say 0.2% so that I can get a very detailed surface 'fit' object that takes into account the trend of my data?
If I use 'linearinterp' for example, I don't think the data is 'smoothened' at all, but rather the surface is forced to pass through all of the scatter points.
Appreciate the help.
Brent

回答 (1 件)

William Rose
William Rose 2022 年 3 月 4 日
編集済み: William Rose 2022 年 3 月 4 日
[edited: fixed the line containing "sum()]
You are right that interpolation is not a smoothing technique in the sense that you want. I assume that line 1 of your original post should have been size [480,1000,3]. Let's call it A. You are reshaping your 2D array into a 1D vector and then smoothing it. That is not a good idea. Points that are next to eachother on the surface will end up far apart in the vector, if they are in the nearby row or column, you know what I mean. Which means the smoothing will not produce the desired result. Instead, make a new surface in which each point in the new surface is the average of a square patch in the original surface:
[m,n]=size(A);
B=zeros(m,n);
w=1; %w=1,2,3... for patches 3x3, 5x5, 7x7, etc.
for i=1+w:m-w, for j=1+w:n-w
B(i,j)=sum(A(i-w:i+w,j-w:j+w),'all')/(2*w+1)^2;
end, end
Try varying the patch size by changing the value of w. Add code to handles the edges and corners as special cases. Or, since your data set is so big, just throw away the edges.

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by