8

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?

Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
dewalla
  • 1,317
  • 8
  • 18
  • 42
  • 4
    You could try to modify [this script](http://www.biometeorology.umn.edu/matlab/logindlg.m) which replaces characters by stars in an edit box in order to implement a password field. – Aabaz Jan 13 '12 at 16:43
  • 1
    I have updated my answer. Please take a look, you might find it helpful now. – Andrey Rubshtein Jan 14 '12 at 14:11

1 Answers1

3

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

Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
  • Look on the [undocumented MATLAB](http://undocumentedmatlab.com/) site. There are a range of posts on using the underlying Java objects. – Nzbuu Jan 13 '12 at 19:52