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 | |
---|
10 | function [ParamOut,errormsg] = set_param_input(ListParam,DefaultValue,ParamIn,Comment) |
---|
11 | errormsg=[]; |
---|
12 | NbParam=numel(ListParam); |
---|
13 | if 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 |
---|
16 | end |
---|
17 | if ~exist('Comment','var') |
---|
18 | Comment=cell(NbParam,1); |
---|
19 | end |
---|
20 | prompt=cell(NbParam,1); |
---|
21 | checknumeric=zeros(NbParam,1); |
---|
22 | for 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 |
---|
32 | end |
---|
33 | dlg_title = 'get the input parameters'; |
---|
34 | answer = inputdlg(ListParam,dlg_title,NbParam,prompt); |
---|
35 | if isempty(answer) |
---|
36 | return |
---|
37 | end |
---|
38 | for ilist=1:NbParam |
---|
39 | if checknumeric(ilist) |
---|
40 | answer{ilist}=str2num(answer{ilist}); |
---|
41 | end |
---|
42 | ParamOut.(ListParam{ilist})=answer{ilist}; |
---|
43 | end |
---|
44 | |
---|