tp@0: function outval = EDB1myvalueinput(textstr,nvalues,minval,maxval) tp@0: % EDB1myvalueinput - Prints a text on the screen and waits for a numerical to be input. tp@0: % Prints the text in textstr, and waits for a numerical to be input. tp@0: % It is checked if these are within the range [minval,maxval]. tp@0: % If one or both is not specified, or given as [], an open range tp@0: % is used. It is also checked if exactly nvalues are input. The tp@0: % values should be input with spaces inbetween. If a negative tp@0: % value of nvalues is input, any number will be accepted. tp@0: % tp@0: % Input parameters: tp@0: % textstr A text str which will be printed on the screen. tp@0: % nvalues The number of numerical values that should be read in from tp@0: % the keyboard. tp@0: % minval (optional) The lowest value that should be allowed. tp@0: % maxval (optional) The highest value that should be allowed. tp@0: % tp@0: % Output parameters: tp@0: % outval The nvalues numerical values that should be read in. tp@0: % tp@0: % Uses the function EDB1extrnums tp@0: % tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % This file is part of the Edge Diffraction Toolbox by Peter Svensson. tp@0: % tp@0: % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify tp@0: % it under the terms of the GNU General Public License as published by the Free Software tp@0: % Foundation, either version 3 of the License, or (at your option) any later version. tp@0: % tp@0: % The Edge Diffraction Toolbox is distributed in the hope that it will be useful, tp@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS tp@0: % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. tp@0: % tp@0: % You should have received a copy of the GNU General Public License along with the tp@0: % Edge Diffraction Toolbox. If not, see . tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % Peter Svensson (svensson@iet.ntnu.no) 20030602 tp@0: % tp@0: % outval = EDB1myvalueinput(textstr,nvalues,minval,maxval); tp@0: tp@0: if nargin < 4 tp@0: maxval = 1e9; tp@0: if nargin < 3 tp@0: minval = -1e9; tp@0: end tp@0: end tp@0: if isempty(maxval) tp@0: maxval = 1e9; tp@0: end tp@0: if isempty(minval) tp@0: minval = -1e9; tp@0: end tp@0: if maxval < minval tp@0: error(['ERROR: minval > maxval']) tp@0: end tp@0: tp@0: foundOKvalue = 0; tp@0: while foundOKvalue == 0 tp@0: outval = EDB1extrnums( input(textstr,'s') ); tp@0: if length(outval) ~= nvalues & nvalues >= 0 tp@0: disp('Wrong number of values!'); tp@0: else tp@0: if prod( double(outval >= minval) ) & prod( double(outval <= maxval) ) tp@0: foundOKvalue = 1; tp@0: else tp@0: disp('One value is outside the allowed range!'); tp@0: end tp@0: end tp@0: end