source: trunk/src/set_param_input.m @ 1154

Last change on this file since 1154 was 1145, checked in by sommeria, 8 months ago

set_param_input added

File size: 1.3 KB
Line 
1% set_param_input: set input parameters for transform functions
2%OUTPUT:
3% ParamOut: structure with parameter values
4%INPUT:
5% LisParam: list of parameter names (cell array)
6% DefaultValue: default values of the parameters in the absence of other input
7% ParamIn: default values set by the structure ParamIn
8
9
10function [ParamOut,errormsg] = set_param_input(ListParam,DefaultValue,ParamIn,Comment)
11errormsg=[];
12NbParam=numel(ListParam);
13if numel(DefaultValue)~=NbParam
14    errorsmsg='ERROR in set_param_input: the list of default values must have the same size as the list of parameters';
15    return
16end
17if ~exist('Comment','var')
18    Comment=cell(NbParam,1);
19end
20prompt=cell(NbParam,1);
21checknumeric=zeros(NbParam,1);
22for ilist=1:numel(ListParam)
23    if isfield(ParamIn,ListParam{ilist})
24        prompt{ilist}=ParamIn.(ListParam{ilist});
25    else
26        prompt{ilist}=DefaultValue{ilist};
27    end
28    if isnumeric(prompt{ilist})
29        checknumeric(ilist)=1;
30        prompt{ilist}=num2str(prompt{ilist});
31    end
32end
33dlg_title = 'get the input parameters';
34answer = inputdlg(ListParam,dlg_title,NbParam,prompt);
35if isempty(answer)
36    return
37end
38for ilist=1:NbParam
39    if checknumeric(ilist)
40        answer{ilist}=str2num(answer{ilist});
41    end
42    ParamOut.(ListParam{ilist})=answer{ilist};
43end
44 
Note: See TracBrowser for help on using the repository browser.