필터 지우기
필터 지우기

Fit surface from Two vectors and a matrix

조회 수: 6 (최근 30일)
Drew Mitchell
Drew Mitchell 2016년 2월 11일
편집: Matt J 2016년 2월 12일
I have two vectors (of different length) that correspond to x and y locations in the x-y plane. I also have the corresponding matrix, z, that gives the hight above the x-y plane for all combinations of x and y( If size(x)=10,1 size(y)=7,1 then size(z)=10,7). I can plot a surface of the data by using surf(x,y,z) and it will work. What I want to do is to be able to fit this surface with a polynomial function of x and y. I am attempting to use fit([x,y],z,'fittype') however this function takes x y and z in the form of vectors only. How do I get the polynomial surface fit from the data I have?
Thanks

채택된 답변

Matt J
Matt J 2016년 2월 11일
편집: Matt J 2016년 2월 11일
[X,Y]=ndgrid(1:10,1:7);
fit([X(:),Y(:)],z(:),'fittype')
  댓글 수: 2
Drew Mitchell
Drew Mitchell 2016년 2월 12일
That was what I needed thanks! Is it possible to get a higher order than poly55? I.e. 5th order for x and 5th order for y? So something 9th order for x and 8th order for y. I get an error when I attempt to go to a greater order than 55. Im atempting to use fit([x y],z,'poly98) Thanks again
Drew
Matt J
Matt J 2016년 2월 12일
편집: Matt J 2016년 2월 12일
I expect that that will be a highly ill-conditioned fitting problem. However, if the Curve Fitting Toolbox won't even attempt it for you, then one of these might:

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

추가 답변 (0개)

카테고리

Help CenterFile 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