Print a statement to the Command Window

10,318 次查看(过去 30 天)
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?
  2 个评论
GOPINATHAN PRAKASH
GOPINATHAN PRAKASH 2021-6-20
Hai navneet nayan,
disp('job done');
disp command is used display the string values.

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2017-5-5
编辑:MathWorks Support Team 2020-2-27
To display text in the Command Window, use disp or fprintf.
disp('job done')
or
fprintf('job done \n')
  2 个评论
Jared MacDonald
Jared MacDonald 2023-5-17,20:23
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

请先登录,再进行评论。

更多回答(5 个)

Gaurav Srivastava
Gaurav Srivastava 2019-5-26
It's not happening. How to display LHS=RHS?Screenshot (9).png
  3 个评论
sidway
sidway 2021-8-13
Try to make a diference between a and b with a tolerance
tol = 1e-3
if abs(a - b) < tol
disp('LHS=RHS')
end

请先登录,再进行评论。


Peyton Spainhour
Peyton Spainhour 2020-10-29
A=6
for k =1:5
if A<=15
A=A + 3
else
A = A+2
end
end
A

Haya Bragg
Haya Bragg 2021-11-29
how to print data file

Dhritishman
Dhritishman 2022-7-10
Use the disp function to print to the command window:
disp('job done')
job done
  3 个评论
Jared MacDonald
Jared MacDonald 2023-5-17,20:24
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

请先登录,再进行评论。


Norah
Norah 2023-4-1
What is the command that writes a message to the screen?

类别

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by