Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you limit what characters can be typed into a MATLAB GUI editbox?

I want to make an editbox in a MATLAB GUI which will only allow numbers or only allow letters to be typed into it. Is this possible?

like image 777
dewalla Avatar asked Jan 13 '12 15:01

dewalla


People also ask

How do I edit a GUI fig in Matlab?

Type guide in command window. A new GUI dialog box will appear. In the dialog box you will select the existing GUI project. To to the tab and you will find the gui file which you want to edit.

How do you allow user input string in Matlab?

x = input( prompt ) displays the text in prompt and waits for the user to input a value and press the Return key. The user can enter expressions, like pi/4 or rand(3) , and can use variables in the workspace. If the user presses the Return key without entering anything, then input returns an empty matrix.

What does %% means in Matlab?

Description: The percent sign is most commonly used to indicate nonexecutable text within the body of a program. This text is normally used to include comments in your code. Some functions also interpret the percent sign as a conversion specifier.


1 Answers

There is no such feature, at least not a documented one. You could assign a callback that will check the input, but that will happen after the user entered illegal character. Though I don't know how exactly to do it, my guess is that you can use Java GUI.
Another interesting option is to add an ActiveX that will do the job.

Edit: I have found an ActiveX that does the job. Downdload it, register by calling

Regsvr32 NumberBox.ocx

And thein add an ActiveX in Matlab Guide. The name will be NumberBox.NbrTextBox. You can do it by cliking the ActiveX button in Guide:

enter image description here

like image 120
Andrey Rubshtein Avatar answered Sep 20 '22 20:09

Andrey Rubshtein