Weighted Polynomial Surface for 3D Points
Show older comments
Hi
I have an mx3 array of point cloud data (X,Y,Z) and a vector of weights for each point (mx1). I'm trying to create a Polynomial Surface (poly22) of the form:
f(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2
From this I need the value of the first coefficient, p00. At the moment I'm using the fit command as follows:
x = XYZ(:,1); % x-column
y = XYZ(:,2); % y-column
Z = XYZ(:,3); % elevation
fitsurface = fit([x,y],z,fittype('poly22'),'Weight',weight);
p00 = fitsurface(0,0);
This works well but is rather slow, considering that this is part of a function I'm working on which acts one-by-one on a point cloud of nearly 2 million points. If the points had no weight, I would use something like:
A = [ones(size(x)) x y x.^2 x.*y y.^2] \ z;
p00 = A(1);
This is much quicker than the 'fit' command; however, I have no idea how to make this work with weights involved. I have also tried the polyfitn function from the File Exchange - around 10% quicker for my dataset.
Any help finding a faster solution to this would be greatly appreciated.
Cheers, Jack
Accepted Answer
More Answers (1)
Image Analyst
on 4 Apr 2015
0 votes
You might want to check this one out also: http://www.mathworks.com/matlabcentral/fileexchange/13719-2d-weighted-polynomial-fitting-and-evaluation. I haven't used it myself though.
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!