Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

MATLAB Basics: GUI input validation 4

Posted by Doug Hull,

Two minute video shows how to validate GUI input. This makes sure that user input will not break your code. This example makes sure that the edit box value is not greater than twelve. This technique can be used for many different tests.
Other videos have been gathered here: Other MATLAB Basics posts have been gathered here:

4 CommentsOldest to Newest

José Ramón Menzinger replied on : 1 of 4
It is a fine Exampla but the code line: set(hObject, 'String', '12'); is IMO not realy adecuate. These kind of declarations will produce "other errors" soon or later... I find better something like: set(hObject, 'String', num2str(modeNum) ); so wenn you mustchange the treshold value you shuoldf change only one value, isn't it? Best regards! J.R.!
Doug replied on : 2 of 4
José, I totally agree with your idea here. In my video series "Cleaner Code in MATLAB" I talk about how you should avoid the use of Magic Numbers. Sometimes I do things for brevity in the videos that I could do better with more time. Thanks! Doug

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide