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?

 채택된 답변

Grzegorz Knor
Grzegorz Knor 2011년 9월 6일

0 개 추천

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