I am trying to use 2D polynomial fitting for my table data, my data format is exactly like the link below:
http://www.mathworks.de/help/toolbox/curvefit/brx2ldg-1.html#bso46rp-1
I mean I have vector X with length n, Y with length m and m*n Matrix Z, I would like to fit 5 degree 2d polynomial to my data,
I am wondering that is there any syntax in MATLAB for solving this problem? like SFIT command in IDL, http://star.pst.qub.ac.uk/idl/SFIT.html
I have cftool and sftool, but it seems that they don’t work for this purpose or most probably I don’t know how to employ them.
and I know that there some m.file which people share in MATLAB Mathworks file exchange, please if you know one works properly, suggest me.
I’d appreciate any help and comment.
You can use polyfitn from file exchange and re-format your data in order to have 3
MxNx,y,zvectors.Example:
Assume you have a table data of the form
Create
meshgridfor x, and y instead(Note that
unique(x)andunique(y)will give you the originallinspacevalues of your table rows and columns.)Use polyfitn to get the 5-degree polynomial coefficients
You can additionally convert the result into a symbolic form to view the polynomial using the provided
polyn2sym(p)