Print a statement to the Command Window (2024)

6,835 views (last 30 days)

Show older comments

NAVNEET NAYAN on 5 May 2017

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window

Commented: Surya on 31 Jul 2024 at 15:07

Accepted Answer: KSSV

I am writing a program. I want to display the statement 'job done' as the output in the Command Window. How can I do it?

3 Comments

Show 1 older commentHide 1 older comment

waleed Al-Qurashi on 16 Feb 2021

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_1331607

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_1331607

3)What is the command that writes a message to the screen?

GOPINATHAN PRAKASH on 20 Jun 2021

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_1593700

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_1593700

Hai navneet nayan,

disp('job done');

disp command is used display the string values.

Surya on 31 Jul 2024 at 15:07

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_3225551

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_3225551

Dpsk output waveform

Sign in to comment.

Sign in to answer this question.

Accepted Answer

KSSV on 5 May 2017

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#answer_265743

Edited: MathWorks Support Team on 27 Feb 2020

Open in MATLAB Online

To display text in the Command Window, use disp or fprintf.

disp('job done')

or

fprintf('job done \n')

3 Comments

Show 1 older commentHide 1 older comment

John Taranto on 23 Mar 2023

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2674220

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2674220

I would not mark this as an accepted answer since it does not solve the problem I detailed.

Jared MacDonald on 17 May 2023

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2750359

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2750359

Hi John,

There is no way to direct output to the Command Window from a live script that you run in the Live Editor.

You can run the live script from the command line; e.g., if your file is myScript.mlx, then

>> myScript

will indeed output to the Command Window (and separate figure windows). But again there's no way to redirect output from the Live Editor. This is something we are investigating, however.

Jared

Justin Bell on 18 Jul 2023

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2820023

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2820023

I just wanted to bump some support for such a feature with live editor. with some larger scripts that can take up to hours of runtime it would be nice to be able to push a "N% complete" or "Error Detected" flag to the window. Not required but would be nice to be able to have the same color options matlab uses for the command window, i.e. disp in default text options with a vargin for red text etc.

Sign in to comment.

More Answers (3)

Gaurav Srivastava on 26 May 2019

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#answer_376664

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#answer_376664

It's not happening. How to display LHS=RHS?Print a statement to the Command Window (10)

3 Comments

Show 1 older commentHide 1 older comment

Christopher Johnston on 21 Jun 2019

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_716858

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_716858

As mentioned by KSSV, you can use fprintf.

For the variables you have shown above:

fprintf('a = %.4f \nb = %.4f \nx = %.4f \n', a, b, x)

This example allows you to print to 4 fixed points of precision, but this can be tailored to your need by changing the number after the '%.' .

Steven Lord on 21 Jun 2019

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_716931

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_716931

Even though a and b are displayed the same, that doesn't mean their contents are the same. The == operator checks for exact down-to-the-last-bit equality. In this case, a and b are close but close doesn't count. See this Answers post for an alternative.

sidway on 13 Aug 2021

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_1686777

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_1686777

Open in MATLAB Online

Try to make a diference between a and b with a tolerance

tol = 1e-3

if abs(a - b) < tol

disp('LHS=RHS')

end

Sign in to comment.

Dhritishman on 10 Jul 2022

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#answer_1004095

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#answer_1004095

Open in MATLAB Online

Use the disp function to print to the command window:

disp('job done')

job done

3 Comments

Show 1 older commentHide 1 older comment

John Taranto on 20 Dec 2022

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2527742

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2527742

Please help me understand this. I use Live Scripts to write my Matlab code. There is a window titled Live Editor - with the path to the mlx file. Separately, there is a Command Window. When I use either the disp() or fprintf() function the output is to the Live Editor Window. I would like to output to the Command Window. How would I do that?

Thanks.

Jack on 23 Mar 2023

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2674085

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2674085

I agreen with @John Taranto. On a .mlx script disp or fprint do not return anything in Command Window, instead it is returned directly underneath the code or to the side depending on your setting. Is there a way to force the text to be displayed in the command window? Thank you in advance

Jared MacDonald on 17 May 2023

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2750364

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#comment_2750364

Hi Jack,

There is no way to direct output to the Command Window from a live script that you run in the Live Editor.

You can run the live script from the command line; e.g., if your file is myScript.mlx, then

>> myScript

will indeed output to the Command Window (and separate figure windows). But again there's no way to redirect output from the Live Editor. This is something we are investigating, however.

Jared

Sign in to comment.

Norah on 1 Apr 2023

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#answer_1206319

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/338836-print-a-statement-to-the-command-window#answer_1206319

What is the command that writes a message to the screen?

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABLanguage FundamentalsEntering Commands

Find more on Entering Commands in Help Center and File Exchange

Tags

  • print
  • output
  • command window

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Print a statement to the Command Window (19)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Print a statement to the Command Window (2024)
Top Articles
Brush Hero Review - Is It A Scam Or Legit? - July 2024 - Honest Product Reviews
30 Richest Superheroes of All Time (Ranked)
What Did Bimbo Airhead Reply When Asked
7 C's of Communication | The Effective Communication Checklist
Craigslist Home Health Care Jobs
Lifewitceee
Http://N14.Ultipro.com
³µ¿Â«»ÍÀÇ Ã¢½ÃÀÚ À̸¸±¸ ¸íÀÎ, ¹Ì±¹ Ķ¸®Æ÷´Ï¾Æ ÁøÃâ - ¿ù°£ÆÄ¿öÄÚ¸®¾Æ
How To Be A Reseller: Heather Hooks Is Hooked On Pickin’ - Seeking Connection: Life Is Like A Crossword Puzzle
Coffman Memorial Union | U of M Bookstores
Wmu Course Offerings
Mylaheychart Login
Craigslist - Pets for Sale or Adoption in Zeeland, MI
Paula Deen Italian Cream Cake
Encore Atlanta Cheer Competition
Readyset Ochsner.org
سریال رویای شیرین جوانی قسمت 338
Eka Vore Portal
6813472639
The Superhuman Guide to Twitter Advanced Search: 23 Hidden Ways to Use Advanced Search for Marketing and Sales
Char-Em Isd
Spergo Net Worth 2022
2020 Military Pay Charts – Officer & Enlisted Pay Scales (3.1% Raise)
Craigslist Missoula Atv
Zoe Mintz Adam Duritz
2024 INFINITI Q50 Specs, Trims, Dimensions & Prices
Robert Deshawn Swonger Net Worth
Cbssports Rankings
Titanic Soap2Day
Phantom Fireworks Of Delaware Watergap Photos
Used Patio Furniture - Craigslist
Margaret Shelton Jeopardy Age
Webworx Call Management
Things to do in Pearl City: Honolulu, HI Travel Guide by 10Best
Our 10 Best Selfcleaningcatlitterbox in the US - September 2024
Www.1Tamilmv.con
Ni Hao Kai Lan Rule 34
Kelsey Mcewen Photos
Pensacola 311 Citizen Support | City of Pensacola, Florida Official Website
Santa Cruz California Craigslist
Is Arnold Swansinger Married
Craigslist Florida Trucks
Seminary.churchofjesuschrist.org
Directions To The Closest Auto Parts Store
Sound Of Freedom Showtimes Near Lewisburg Cinema 8
Tricia Vacanti Obituary
Costco Gas Foster City
Quaally.shop
Avance Primary Care Morrisville
Timothy Warren Cobb Obituary
My Gsu Portal
About us | DELTA Fiber
Latest Posts
Article information

Author: Pres. Carey Rath

Last Updated:

Views: 5492

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Pres. Carey Rath

Birthday: 1997-03-06

Address: 14955 Ledner Trail, East Rodrickfort, NE 85127-8369

Phone: +18682428114917

Job: National Technology Representative

Hobby: Sand art, Drama, Web surfing, Cycling, Brazilian jiu-jitsu, Leather crafting, Creative writing

Introduction: My name is Pres. Carey Rath, I am a faithful, funny, vast, joyous, lively, brave, glamorous person who loves writing and wants to share my knowledge and understanding with you.