How to get fitting parameter in sftool.
1 view (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Grzegorz Knor
on 6 Sep 2011
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 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!