| 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 | ParamOut=[]; |
|---|
| 12 | errormsg=[]; |
|---|
| 13 | NbParam=numel(ListParam); |
|---|
| 14 | if numel(DefaultValue)~=NbParam |
|---|
| 15 | errorsmsg='ERROR in set_param_input: the list of default values must have the same size as the list of parameters'; |
|---|
| 16 | return |
|---|
| 17 | end |
|---|
| 18 | if ~exist('Comment','var') |
|---|
| 19 | Comment=cell(NbParam,1); |
|---|
| 20 | end |
|---|
| 21 | prompt=cell(NbParam,1); |
|---|
| 22 | checknumeric=zeros(NbParam,1); |
|---|
| 23 | for ilist=1:numel(ListParam) |
|---|
| 24 | if isfield(ParamIn,ListParam{ilist}) |
|---|
| 25 | prompt{ilist}=ParamIn.(ListParam{ilist}); |
|---|
| 26 | else |
|---|
| 27 | prompt{ilist}=DefaultValue{ilist}; |
|---|
| 28 | end |
|---|
| 29 | if isnumeric(prompt{ilist}) |
|---|
| 30 | checknumeric(ilist)=1; |
|---|
| 31 | prompt{ilist}=num2str(prompt{ilist}); |
|---|
| 32 | end |
|---|
| 33 | end |
|---|
| 34 | dlg_title = 'get the input parameters'; |
|---|
| 35 | options.Resize='on'; |
|---|
| 36 | answer = inputdlg(ListParam,dlg_title,NbParam,prompt,options); |
|---|
| 37 | %answer = msgbox_uvmat('INPUT_TXT',ListParam); |
|---|
| 38 | if isempty(answer) |
|---|
| 39 | return |
|---|
| 40 | end |
|---|
| 41 | for ilist=1:NbParam |
|---|
| 42 | if checknumeric(ilist) |
|---|
| 43 | answer{ilist}=str2num(answer{ilist}); |
|---|
| 44 | end |
|---|
| 45 | ParamOut.(ListParam{ilist})=answer{ilist}; |
|---|
| 46 | end |
|---|
| 47 | |
|---|