source: MML/trunk/machine/SOLEIL/common/toolbox/ezyfit/ezyfit/editcoeff.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 2.4 KB
Line 
1function c=editcoeff(f)
2%EDITCOEFF  Edit the coefficients of a fit
3%   EDITCOEFF opens the Matlab's Array Editor to edit the coefficients
4%   of the last fit (which is stored in the variable 'lastfit'). This may
5%   be useful to copy/paste the fit coefficients into a spreadsheet
6%   (see the setting 'coeffarray' in FITPARAM to change the row/column
7%   display).
8%
9%   EDITCOEFF is also available from the item 'Edit Fit Coefficients' in
10%   the EzyFit menu, and can be automatically called after each fit (see
11%   the setting 'editcoeffmode' in FITPARAM).
12%
13%   EDITCOEFF(F) opens the Matlab's Array Editor to edit the coefficients
14%   of the fit F. (F is a fit structure as returned by EZFIT or SHOWFIT).
15%
16%   C = EDITCOEFF(...) returns a 2xN cell array, containing the
17%   coefficients names and values.
18%
19%   Example:
20%     plotsample('power');
21%     f = ezfit('power');
22%     editcoeff(f);
23%
24%   See also EZFIT, SHOWFIT, EFMENU, FITPARAM, MAKEVARFIT, OPENVAR.
25
26%   F. Moisy, moisy_at_fast.u-psud.fr
27%   Revision: 1.00,  Date: 2006/02/09
28%   This function is part of the EzyFit Toolbox
29
30% History:
31% 2006/02/09: v1.00, first version.
32
33
34% if no input argument, use the last fit, which is stored
35% in the variable lastfit in the 'base' workspace:
36if nargin==0,
37    if evalin('base','exist(''lastfit'',''var'')')
38        f=evalin('base','lastfit');
39    else
40        errordlg('No existing fit coefficients. First fit a curve.',...
41            'Edit Fit Coefficients','on');
42        return;
43    end;
44end;
45
46
47if exist('fitparam.m','file'),
48    fp=fitparam;
49else
50    error('No fitparam file found.');
51end;
52
53
54% c is a 2xN cell array containing the parameter
55% names and the parameter values
56for i=1:length(f.param);
57    c{i,1}=f.param{i};
58    c{i,2}=f.m(i);       
59end;
60
61switch fp.corrcoefmode
62    case 'r'
63        c{length(f.param)+1,1}='R';
64        c{length(f.param)+1,2}=f.r;
65    case 'r2',
66        c{length(f.param)+1,1}='R^2';
67        c{length(f.param)+1,2}=f.r^2;
68end;
69
70% displays the coeff in row or in column:
71if ~strcmpi(fp.coeffarray,'row'),
72    c=c';
73end;
74
75% creates a variable called 'FitCoefficients' in the matlab 'base' workspace
76% (this is required for using openvar)
77assignin('base','FitCoefficients',c)
78
79% calls the Array Editor with this variable "FitCoefficients".
80openvar('FitCoefficients');
81
82if nargout==0
83    clear c
84end;
Note: See TracBrowser for help on using the repository browser.