{"id":2564,"date":"2010-05-21T15:04:18","date_gmt":"2010-05-21T15:04:18","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2010\/05\/21\/input-made-easy\/"},"modified":"2010-05-21T15:04:18","modified_gmt":"2010-05-21T15:04:18","slug":"input-made-easy","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2010\/05\/21\/input-made-easy\/","title":{"rendered":"Input Made Easy"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26312-settings-dialog\"><tt>settingsdlg<\/tt><\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/45753\">Rody Oldenhuis<\/a>.\r\n   <\/p>\r\n   <p>Last December, I wrote this <a href=\"https:\/\/blogs.mathworks.com\/pick\/2009\/12\/25\/input-dialog-box-on-steroids\/\">post<\/a> on <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/25862-inputsdlg--enhanced-input-dialog-box\"><tt>inputsdlg<\/tt><\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/36665\">Kesh<\/a>. I really liked the flexibility of <tt>inputsdlg<\/tt> in creating a complex user input dialog. Today, I came across <tt>settingsdlg<\/tt> by Rody. There are a lot of similarities between the two functions. For example, they both allow prompting for multiple inputs,\r\n      specifying input format, and storing output as a structure. While the customizability of <tt>settingsdlg<\/tt> is not as exhaustive as <tt>inputsdlg<\/tt>, I am impressed at the ease of use of the function.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">[settings, button] = settingsdlg(<span style=\"color: #0000FF\">...<\/span>\r\n   <span style=\"color: #A020F0\">'Description'<\/span>                        , [<span style=\"color: #A020F0\">'This dialog will set the '<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n                                          <span style=\"color: #A020F0\">'parameters used by FMINCON()'<\/span>], <span style=\"color: #0000FF\">...<\/span>\r\n   <span style=\"color: #A020F0\">'title'<\/span>                              , <span style=\"color: #A020F0\">'FMINCON() options'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n   <span style=\"color: #A020F0\">'separator'<\/span>                          , <span style=\"color: #A020F0\">'Unconstrained\/General'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n   {<span style=\"color: #A020F0\">'This is a checkbox'<\/span>; <span style=\"color: #A020F0\">'Check'<\/span>}      , [false, false],<span style=\"color: #0000FF\">...<\/span>\r\n   {<span style=\"color: #A020F0\">'Tolerance X'<\/span>;<span style=\"color: #A020F0\">'TolX'<\/span>}               , 1e-6, <span style=\"color: #0000FF\">...<\/span>\r\n   {<span style=\"color: #A020F0\">'Tolerance on Function'<\/span>;<span style=\"color: #A020F0\">'TolFun'<\/span>}   , 1e-6, <span style=\"color: #0000FF\">...<\/span>\r\n   <span style=\"color: #A020F0\">'Algorithm'<\/span>                          , {<span style=\"color: #A020F0\">'active-set'<\/span>,<span style=\"color: #A020F0\">'interior-point'<\/span>}, <span style=\"color: #0000FF\">...<\/span>\r\n   <span style=\"color: #A020F0\">'separator'<\/span>                          , <span style=\"color: #A020F0\">'Constrained'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n   {<span style=\"color: #A020F0\">'Tolerance on Constraints'<\/span>;<span style=\"color: #A020F0\">'TolCon'<\/span>}, 1e-6)<\/pre><pre style=\"font-style:oblique\">settings = \r\n        Check: 0\r\n         TolX: 1.0000e-006\r\n       TolFun: 1.0000e-006\r\n    Algorithm: 'active-set'\r\n       TolCon: 1.0000e-006\r\nbutton =\r\nok\r\n<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/settingsdlg_screenshot.png\"> <\/p>\r\n   <p>As you can see, it takes parameter-value pairs. The type of input is automatically determined by the value: numbers and strings\r\n      use edit boxes, cell arrays use list boxes, and logical arrays use check boxes. You can also group fields by creating separators.\r\n   <\/p>\r\n   <p>I also like the detailed documentation (.pdf) that Rody includes with the entry. And finally, if you're looking for an example\r\n      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\r\n      it robust.\r\n   <\/p>\r\n   <p><a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2564#respond\">Comments<\/a>?\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_c2a1ed35e87f4f159bc0c43db3c55ebc() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='c2a1ed35e87f4f159bc0c43db3c55ebc ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' c2a1ed35e87f4f159bc0c43db3c55ebc';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Jiro Doke';\r\n        copyright = 'Copyright 2010 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_c2a1ed35e87f4f159bc0c43db3c55ebc()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.10<br><\/p>\r\n<\/div>\r\n<!--\r\nc2a1ed35e87f4f159bc0c43db3c55ebc ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26312-settings-dialog\r\n% |settingsdlg|> by \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/45753\r\n% Rody Oldenhuis>.\r\n%\r\n% Last December, I wrote this\r\n% <https:\/\/blogs.mathworks.com\/pick\/2009\/12\/25\/input-dialog-box-on-steroids\/\r\n% post> on\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/25862-inputsdlg--enhanced-input-dialog-box\r\n% |inputsdlg|> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/36665 Kesh>.\r\n% I really liked the flexibility of |inputsdlg| in creating a complex user\r\n% input dialog. Today, I came across |settingsdlg| by Rody. There are a lot\r\n% of similarities between the two functions. For example, they both allow\r\n% prompting for multiple inputs, specifying input format, and storing\r\n% output as a structure. While the customizability of |settingsdlg| is not\r\n% as exhaustive as |inputsdlg|, I am impressed at the ease of use of the\r\n% function.\r\n\r\n[settings, button] = settingsdlg(...\r\n   'Description'                        , ['This dialog will set the ', ... \r\n                                          'parameters used by FMINCON()'], ...\r\n   'title'                              , 'FMINCON() options', ...\r\n   'separator'                          , 'Unconstrained\/General', ...\r\n   {'This is a checkbox'; 'Check'}      , [false, false],...\r\n   {'Tolerance X';'TolX'}               , 1e-6, ...\r\n   {'Tolerance on Function';'TolFun'}   , 1e-6, ...\r\n   'Algorithm'                          , {'active-set','interior-point'}, ...\r\n   'separator'                          , 'Constrained', ...\r\n   {'Tolerance on Constraints';'TolCon'}, 1e-6)\r\n\r\n%%\r\n% <<settingsdlg_screenshot.png>>\r\n%\r\n% As you can see, it takes parameter-value pairs. The type of input is\r\n% automatically determined by the value: numbers and strings use edit\r\n% boxes, cell arrays use list boxes, and logical arrays use check boxes.\r\n% You can also group fields by creating separators.\r\n%\r\n% I also like the detailed documentation (.pdf) that Rody includes with the\r\n% entry. And finally, if you're looking for an example of a well-written\r\n% MATLAB code, take a look at this entry. It's very well-commented and has\r\n% a lot of error checking to make it robust.\r\n%\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2564#respond Comments>?\r\n##### SOURCE END ##### c2a1ed35e87f4f159bc0c43db3c55ebc\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Jiro's pick this week is settingsdlg by Rody Oldenhuis.\r\n   \r\n   Last December, I wrote this post on inputsdlg by Kesh. I really liked the flexibility of inputsdlg in creating a complex user... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/05\/21\/input-made-easy\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2564"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2564"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2564\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}