Home > src > validateRealNumber.m

# validateRealNumber

## PURPOSE

- helper function to validate that a string represents a real number

## SYNOPSIS

function flag = validateRealNumber(strNum,errmsg,errtitle)

## DESCRIPTION

     - helper function to validate that a string represents a real number

     copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut

        This file is part of SOS

        SOS is free software: you can redistribute it and/or modify
        it for academic and non-commercial purposes
        under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.  For commercial or for-profit
        uses, please contact the authors (sos@cnbc.cmu.edu).

        SOS is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- createHardBoundConstraint_Dialog - create hard bound constraint dialog
- createMatchUniformkstest_Dialog - create uniformity ks-test dialog
- createSingleSampleSoftDistanceConstraint_Dialog - create single sample soft distance constraint dialog
- createSoftEntropyConstraint_Dialog - create soft entropy constraint dialog
- createSoftMatchCorrelDistanceConstraint_Dialog - create soft match correlation constraint dialog
- createSoftMetaConstraint_Dialog - create soft meta-constraint dialog
- createTwoSampleSoftDistanceConstraint_Dialog - create two sample soft distance constraint dialog
- createsinglesamplettest_Dialog - create single sample t-test dialog
- expAnneal_Dialog - create expAnneal dialog
- maxpDecrease_Dialog dialog used for calculating the largest p-decrease value
- numSteps_Dialog dialog used to calculate the nubmer of temperature-lowering steps

## SOURCE CODE

    0001 % - helper function to validate that a string represents a real number
    0002 %
    0003 % copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut
    0004 %
    0005 %    This file is part of SOS
    0006 %
    0007 %    SOS is free software: you can redistribute it and/or modify
    0008 %    it for academic and non-commercial purposes
    0009 %    under the terms of the GNU General Public License as published by
    0010 %    the Free Software Foundation, either version 3 of the License, or
    0011 %    (at your option) any later version.  For commercial or for-profit
    0012 %    uses, please contact the authors (sos@cnbc.cmu.edu).
    0013 %
    0014 %    SOS is distributed in the hope that it will be useful,
    0015 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
    0016 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0017 %    GNU General Public License for more details.
    0018
    0019 %    You should have received a copy of the GNU General Public License
    0020 %    along with SOS (see COPYING.txt).
    0021 %    If not, see <http://www.gnu.org/licenses/>.
    0022
    0023 function flag = validateRealNumber(strNum,errmsg,errtitle)
    0024     % validates that the string represents a real number
    0025
    0026     valid = str2double(strNum);
    0027
    0028     if isnan(valid)
    0029         % name is not currently valid, tell the user.
    0030         msgbox(errmsg,...
    0031                 errtitle);
    0032        flag = false;
    0033     else
    0034         flag = true;
    0035     end
    0036
    0037
    0038
    0039 end
    0040