Skip to content
Related Articles

Related Articles

Simple Input/Output Program in MATLAB
  • Last Updated : 20 Aug, 2020

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

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 : GeeksforGeeks
ans = GeeksforGeeks

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("GeeksforGeeks")
  
% output a variable
var = 10;
display(var)

Output :

GeeksforGeeks
var =  10
My Personal Notes arrow_drop_up
Recommended Articles
Page :