[TOC]

input

Prompt for user input

Usage

input(prompt)

a = input(prompt)

input(prompt, 's')

a = input(prompt, 's')

Examples

Input
num=input('Pls enter a number:');
disp('The number is:')
disp(num)
Output
% Output
Pls enter a number:

1;

The number is:

 1.000
Input
fact=input('Pls tell me a fact:','s');
disp(['You have told me: ' fact])
Output
Pls tell me a fact:

The sky is blue

You have told me: The sky is blue
Input
while true
    age=input('Guess my age');
    disp(['You have entered ' num2str(age)]);
    confirm=input('Confirm? [true/false]');
    if confirm
        if age == 20
            disp('Great! You are right')
        else
            disp('Sorry. You are wrong')
        end
        break
    end
end
Output
Guess my age

20;

You have entered 20.00

Confirm? [true/false]

true;

Great! You are right
Input
a=input('Enter an expression:');
disp(['the result is ' num2str(a)])
Output
Enter an expression:

1+3/4;

the result is 1.750