How do I print (output) in Matlab? - dspGuru (2024)

There are three common ways:

  1. Type the name of a variable without a trailing semi-colon.
  2. Use the “disp” function.
  3. Use the “fprintf” function, which accepts a C printf-style formatting string.

Here are examples:

> x = [1 2 3 4];> xx = 1 2 3 4> disp(x) 1 2 3 4> fprintf('%i\n', x)1234

Notes:

  • “disp” excludes the variable name from the output
  • “fprintf” uses the formatting string on each element of the variable. In the example above, applying “\n” to each element had the net effect of printing a row vector as if it were a column vector.
How do I print (output) in Matlab? - dspGuru (2024)
Top Articles
Latest Posts
Article information

Author: Duane Harber

Last Updated:

Views: 5864

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.