How to hide 'ans= ' in sprintf output?

조회 수: 54 (최근 30일)
Tazuddin
Tazuddin 2014년 10월 17일
댓글: Image Analyst 2021년 7월 24일
I want to hide the 'ans=' line before output which appear automatically every time before output.

답변 (2개)

Image Analyst
Image Analyst 2014년 10월 17일
Assign it to something.
str = sprintf('The result = %s', result)
It will say str=whatever instead of ans = whatever. If you don't even want that then put a semicolon at the end of the line.
str = sprintf('The result = %s', result);
Now nothing at all will show up in the command window. If you don't want to assign it to a variable but just want some string to be printed to the command window without ans= in front of it then use fprintf() instead of sprintf():
fprintf('The result = %s\n', result);

Henrik
Henrik 2014년 10월 17일
Terminate the line with a semicolon:
sprintf('The array is %dx%d.',2,3);
  댓글 수: 2
Joshua McDonald
Joshua McDonald 2021년 7월 24일
When I do that all I get is the file name as an output >> fileName
Image Analyst
Image Analyst 2021년 7월 24일
@Joshua McDonald, I think you replied to the wrong post. Your reply has nothing to do with @Tazuddin's Question or @Henrik's Answer.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by