input()

Syntax : input(PROMPT, “s”)

Parameters :

  • PROMPT : text prompted
  • “s” : optional, to input a string

Returns : the data entered

The input() function is used to input data in MATLAB.
Example :




% entering an integer
input("Enter an integer : ")
  
% entering a string
input("Enter a string : ", "s")


Output :

Enter an integer : 10
ans =  10
Enter a string : w3wiki
ans = w3wiki

display()

Syntax : display(OBJ)

Parameters :

  • OBJ : the object to be displayed

Returns : Nothing

The display() function is used to output data in MATLAB.

Example :




% output a string
display("w3wiki")
  
% output a variable
var = 10;
display(var)


Output :

w3wiki
var =  10

Simple Input/Output Program in MATLAB

Let us see how to input and output data in MATLAB.

Similar Reads

input()

Syntax : input(PROMPT, “s”) Parameters : PROMPT : text prompted “s” : optional, to input a string Returns : the data entered...

Contact Us