Input Made Easy
Jiro's pick this week is settingsdlg by Rody Oldenhuis.
Last December, I wrote this post on inputsdlg by Kesh. I really liked the flexibility of inputsdlg in creating a complex user input dialog. Today, I came across settingsdlg by Rody. There are a lot of similarities between the two functions. For example, they both allow prompting for multiple inputs, specifying input format, and storing output as a structure. While the customizability of settingsdlg is not as exhaustive as inputsdlg, I am impressed at the ease of use of the function.
[settings, button] = settingsdlg(... 'Description' , ['This dialog will set the ', ... 'parameters used by FMINCON()'], ... 'title' , 'FMINCON() options', ... 'separator' , 'Unconstrained/General', ... {'This is a checkbox'; 'Check'} , [false, false],... {'Tolerance X';'TolX'} , 1e-6, ... {'Tolerance on Function';'TolFun'} , 1e-6, ... 'Algorithm' , {'active-set','interior-point'}, ... 'separator' , 'Constrained', ... {'Tolerance on Constraints';'TolCon'}, 1e-6)
settings = Check: 0 TolX: 1.0000e-006 TolFun: 1.0000e-006 Algorithm: 'active-set' TolCon: 1.0000e-006 button = ok
As you can see, it takes parameter-value pairs. The type of input is automatically determined by the value: numbers and strings use edit boxes, cell arrays use list boxes, and logical arrays use check boxes. You can also group fields by creating separators.
I also like the detailed documentation (.pdf) that Rody includes with the entry. And finally, if you're looking for an example of a well-written MATLAB code, take a look at this entry. It's very well-commented and has a lot of error checking to make it robust.
- カテゴリ:
- Picks
コメント
コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。