Get the coefficients in a vector from cftool ?
4 visualizzazioni (ultimi 30 giorni)
In my script (*.m file), I would like to use cftool to get the 15 coefficients from a polynomial function (degrees 4) and put them in a vector. This vector will be use latter in my script. It have to be done without configuring the parameters in cftool windows. I would like everything to be automatic.
Any ideas to do it with cftool ? I already tried with fittype but it don't allow a so big z matrix (x and y are 1x17 vectors and z is a 17x17 matrix for example).
Kind regards, Seb
Modificato: Greig il 23 Feb 2015
To extract the coefficients use the "fit" function....
[fitobject,gof,output]=fit([x, y], z, 'poly44');
fitobject.p00, fitobject.p10, fitobject.p01, etc contain all of the coefficients. So,
Coeffs = [fitobject.p00, fitobject.p10, fitobject.p01,....
is your vector of coefficients.
For more info type
[Edit: First post was a solution for curve fitting, then I realised you were surface fitting.]
You'll need to do some reshaping as fit expects column vectors for x, y and z. If I have my dimensions correct, something like this should work.
x2=reshape(meshgrid(x,y), numel(z), 1);
y2=repmat(y, 15, 1);
z2=reshape(z, numel(z), 1);
[fitobject,gof,output]=fit([x2, y2], z2, 'poly44');