numeric UI Control

Version 1.5.0.0 (11.1 KB) by Kyle
Make a custom ui control that is an editbox that only allows numeric inputs.
394 Downloads
Updated 28 Feb 2012

View License

Allow a uicontrol that is an edit box that only allows numeric inputs. There are different types of inputs (ie integers, non-negative, scalars). The top level command is numericEdit. There are also sub files that are helpful like customControl that can be used independently.

Requires matlab version that can utilize classdef.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% numericEdit
%
% h = numericEdit(numericType, AllowDecimal, AllowNegative, 'parameter,
% 'value', ...)
%
% Creates a uicontrol edit box that must be numeric.
% NOTE: fixing non numeric inputs relies on a timer object and is thus
% not incredibly reliable.
%
% Types of numeric are accessed by numericEdit. (various types)
% ONLY_NUMERIC_CHARACTERS:
% literally only characters "-", and 0-9. are allowed
% ONLY_NUMERIC_RESULT:
% the result will be checked after enter is finished and attempt to
% convert input into a numeric, ie pi will result in 3.14159 even
% though pi explicity is not 0-9.
% ONLY_LENGTH_ONE_NUMERIC_RESULT:
% Check the result and must be numeric with length=1
%
% AllowDecimal is a boolean to allow not integer data
% AllowNegative is a boolean to allow negative numbers
%
% Example
% numericEdit(numericEdit.ONLY_NUMERIC_CHARACTERS, true, true, 'width',10)
%
% See also customControl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cite As

Kyle (2024). numeric UI Control (https://www.mathworks.com/matlabcentral/fileexchange/35095-numeric-ui-control), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Migrate GUIDE Apps in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.5.0.0

updated tags

1.4.0.0

updated tags

1.3.0.0

missing enum file included in zip

1.0.0.0