How to find an equation to fitting surface?
1 次查看(过去 30 天)
显示 更早的评论
I have a 100x100 matrix, which contains 10000 different values
Use of imagec instruction drawing as follows
I want to find an equation to fitting this surface
How to do?
Thanks~!!
2 个评论
Matt J
2012-10-23
The surface doesn't look like a plane to me. Are you sure that's how you want the fit to model it. If not, why does your title say that you're fitting a plane?
回答(2 个)
Valter Zöldhegyi
2019-5-7
Without toolbox: you can use the polyfitn function by John D'Errico: https://www.mathworks.com/matlabcentral/fileexchange/34765-polyfitn
Considering your example:
myIn = NaN(10000, 3);
myIn(:,1) = repmat((0:1:99, 1, 100); %x
myIn(:,2) = repelem(0:1:99, 100); %y
myIn(:,3) = myData(:); % z, myData is the 100x100 matrix you have
myModel = polyfitn([myIn(:,1),myIn(:,2)],myIn(:,3),4); % x and y is the depending variable, z is the independant variable, 4 is the degree of the polynom
In the myModel struct you will have the ModelTerms and the Coefficients fields. ModelTerms matrix defines the term used (eg. a row with [0 0] means a constant; row [1 1] is a x*y term). The coefficients for each term can be found in the Coefficients vector.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!