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 ExchangeGet 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