Problems fitting a plane using cftool

4 ビュー (過去 30 日間)
Nathan
Nathan 2013 年 9 月 2 日
I'm having an issue fitting a plane to a 3d data set using the cftool. I have lots of these data sets, and every once and a while, the plane fit it gives me is clearly way off, and I have no idea why.
Here is the piece of code I'm using, its pretty basic:
X = data(:,1);
Y = data(:,2);
Z = data(:,3);
fitobject = fit( [ X, Y], Z, fittype('poly11'));
Fitted_plane = [ fitobject.p00 , fitobject.p10 , fitobject.p01 ];
And to give you an idea of what the fit looks like:
And the fit is clearly not correct, but I cannot for the life of me figure out how to fix it. This happens for maybe 1/10 of the fits I'm doing, and I was wondering if maybe there is a problem with the toolbox? I can definitely send out the data set, I just didnt want to post the whole thing here.
Thanks in advance.

採用された回答

Matt J
Matt J 2013 年 9 月 3 日
編集済み: Matt J 2013 年 9 月 3 日
From your plots, it looks like the 3D plane containing your data could be of the form
a*X + b*Y + c*Z = d
but with c=0. Obviously, when c=0, this cannot be rewritten as a function Z(X,Y), as you are trying to do.
The following is a way to fit the plane without CFTOOL and it works for all plane orientations,
m=mean(data,1);
[~,~,v]=svd( bsxfun(@minus, data, m) ,0);
abc=v(:,end); %plane normal vector
d=dot(abc,m); %distance from origin
a=abc(1); b=abc(2); c=abc(3);
  2 件のコメント
Nathan
Nathan 2013 年 9 月 3 日
編集済み: Nathan 2013 年 9 月 3 日
Thanks, then given that this gives a unit normal vector and d, what is the easiest way to create a plot of the plane from this data?
Thanks
Matt J
Matt J 2013 年 9 月 3 日
編集済み: Matt J 2013 年 9 月 3 日
If you have the Symbolic Toolbox, this
seems to work well. And even if you don't, it's not too hard to modify the file.

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

その他の回答 (0 件)

カテゴリ

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