numeric UI Control
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
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.