Output function

Raheelanjum
3 min readDec 10, 2024

The input function allows you to ask a user to type some sort of information into the program and to save that information into a variable that the program can process.

The Input Function

The input function is used to ask the user of the program (not the programmer) a question and then wait for a typed response. The typed number is then returned as the result of the function and should usually be stored in a variable:

Reading Strings

By default, the input function expects to read a number, and if the user types hello, it will assume that hello is a variable containing a number. If you really want the string "hello," then you would have to type 'hello' (tick marks).

To tell a Matlab program to read a string of characters directly without having to type the tick marks, you must use the 's' syntax as shown here:

The input function is similar (but more user friendly) to the scanf function in C. Thus, in C, if you wish to receive input from the user of the program, you must use the scanf (or fgets) function.

Asking for input using a complex string

--

--

Raheelanjum
Raheelanjum

Written by Raheelanjum

Highly skilled and experienced content writer dedicated to crafting compelling, informative content that resonates with diverse audiences. Expertise spans blog

Responses (18)