How to get fitting parameter in sftool.

I have three parameters as x, y, z.
I want to fit these parameters as z = a*x + b*y.
After I finish fitting at sftool. I generate M-file. By modify this M-file, I want to save fitting parameter a and b at work space.
How could I do this?

 采纳的回答

The generated code should look something like this:
%%Initialization.
% Convert all inputs to column vectors.
x = x(:);
y = y(:);
z = z(:);
%%Fit: 'untitled fit 1'.
ft = fittype( 'poly11' );
opts = fitoptions( ft );
opts.Weights = zeros(1,0);
[fitresult, gof] = fit( [x, y], z, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, [x, y], z );
legend( h, 'untitled fit 1', 'z vs. x, y', 'Location', 'NorthEast' );
% Label axes
xlabel( 'x' );
ylabel( 'y' );
zlabel( 'z' );
grid on
And fitting parameters are stored in fitresult:
fitresult.p00
fitresult.p01
fitresult.p10

更多回答(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