Simple Input/Output Program in MATLAB

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 :



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

GeeksforGeeks
var =  10

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.