1 | function makevarfit(f)
|
---|
2 | %MAKEVARFIT Create variables from the parameters of a fit
|
---|
3 | % MAKEVARFIT(F) creates (in the Matlab workspace) the variables that
|
---|
4 | % contain the numerical values of the parameters from the fit F.
|
---|
5 | %
|
---|
6 | % If you want the variables to be automatically created in the Matlab
|
---|
7 | % workspace at each call of ezfit, showfit or selectfit, set the option
|
---|
8 | % 'automakevarfit = on' in fitparam.
|
---|
9 | %
|
---|
10 | % If the input argument F is not specified, use the last fit.
|
---|
11 | %
|
---|
12 | % Example:
|
---|
13 | % Some sample data are fitted by a 2nd order polynom, and the
|
---|
14 | % three variables 'a','b','c', which contain the numerical values
|
---|
15 | % of the parameters, are created in the workspace:
|
---|
16 | % plotsample('poly2');
|
---|
17 | % f = showfit('a*x^2+b*x+c');
|
---|
18 | % makevarfit(f);
|
---|
19 | % whos
|
---|
20 | %
|
---|
21 | % See also EZFIT, SHOWFIT, EDITCOEFF.
|
---|
22 |
|
---|
23 | % F. Moisy, moisy_at_fast.u-psud.fr
|
---|
24 | % Revision: 1.00, Date: 2006/02/15
|
---|
25 | % This function is part of the EzyFit Toolbox
|
---|
26 |
|
---|
27 | % History:
|
---|
28 | % 2006/02/15: v1.00, first version.
|
---|
29 |
|
---|
30 |
|
---|
31 | % if no input argument, use the last fit, which is stored
|
---|
32 | % in the variable lastfit in the 'base' workspace:
|
---|
33 | if nargin==0,
|
---|
34 | if evalin('base','exist(''lastfit'',''var'')')
|
---|
35 | f=evalin('base','lastfit');
|
---|
36 | else
|
---|
37 | errordlg('No existing fit coefficients. First fit a curve.',...
|
---|
38 | 'Edit Fit Coefficients','on');
|
---|
39 | return;
|
---|
40 | end;
|
---|
41 | end;
|
---|
42 |
|
---|
43 | % create the variable f.param{i} containing the value f.m(i):
|
---|
44 | for i=1:length(f.param)
|
---|
45 | assignin('base',f.param{i},f.m(i));
|
---|
46 | end;
|
---|