inp.m
The function implements keyboard input supported by a default value. A user may either accept the default value or enter a new one. Controlled input of data from the keyboard is advantageous for debugging, making protocols via function diary, parametric studies when changing parameters depending on a result of the current iteration, branching run of a program under user wishes, etc, all without debugging.
Forms of a call:
~~~~~~~~~~~~~~~~
inp % display help
data = inp; % similar to input('input')
data = inp(prompt); % similar to input(prompt)
data = inp(prompt,deflt);
data = inp(prompt,deflt,form);
data = inp(prompt,deflt,form,nsp);
% prompt = string of characters
% input with a default value of input data
% form = format of the screen output; default '%9.4f'; format is persistent until new value is given
% nsp = number of leading spaces before prompt on screen; nsp = 10 is persistent until a new value is given
% data = either deflt value if accepted by ENTER, or a new input value
Examples:
~~~~~~~~~
p = inp('pressure [MPa]',7.5); % if no new value is given, p=7.5
if strcmp(inp('Continue','yes'),'yes') % for user's on-line decission
% True branch
else
% False branch
end
A = eval(inp('A','[B,x]')); % A = [B,x] if no new input
cx = inp('cxconst',1+i*pi); % gives cx = 1+3.14159i, if accepted
Citation pour cette source
Miroslav Balda (2024). inp.m (https://www.mathworks.com/matlabcentral/fileexchange/9033-inp-m), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxCatégories
Tags
Remerciements
A inspiré : SINIDE - Parameter identification of a sine-wave from a measured signal
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Version | Publié le | Notes de version | |
---|---|---|---|
1.1.0.0 | Implemented better displaying of comples numbers. Improved description. |
||
1.0.0.0 | Improving description |