Fitting a surface over a mxn matrix

Hi,
I have a function u(x,y) which I wish to fit using the 'poly11' option within the 'fit' funtion The problem is that x, y, and u are all m x n matrices with m not equal to n. I can fit the data using the sftool but I would like to do it in a programmatic way. Any help will be greatly appreciated.
Thanks, Andy

 채택된 답변

Walter Roberson
Walter Roberson 2011년 10월 3일

0 개 추천

Poking around a bit, poly11 appears to fit a polynomial of the form a*x + b*y + c. I could be wrong on that, perhaps there is an x*y term as well, but my interpretation of the documentation is that there is no x*y term.
If your equation to fit is indeed of the form a * x + b * y + c, then it can be rewritten as being of the form
U = [x y 1] * [a;b;c]
where [a;b;c] are unknowns to determine.
This can then be rewritten as a simple mldivide ('\') operation:
U(:) \ [x(:) y(:) ones(numel(x),1)]
or some close relative thereof (I keep forgetting the order of the components)

댓글 수: 2

Andres
Andres 2011년 10월 3일
In fact poly11 fits a function of the form f(x,y) = a + b*x + c*y. By using your method wouldn't I get the coefficients a, b, and c which are each m x n matrices since x and y are both m x n?
Walter Roberson
Walter Roberson 2011년 10월 3일
Notice the (:) that I used: that turns the arrays in to column vectors. U(:) will be an n*m x 1 column vector, the part to the right will be an n*m x 3 array, and the result of fitting will be a 3 x 1 array (provided I got the terms in the right order: see mldivide for examples.)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터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!

Translated by