File Exchange Pick of the Week

May 21st, 2010

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.

Comments?


Get the MATLAB code

Published with MATLAB® 7.10

One Response to “Input Made Easy”

  1. EliteHussar replied on :

    Thank you a lot

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.