How to hide 'ans= ' in sprintf output?
54 次查看(过去 30 天)
显示 更早的评论
I want to hide the 'ans=' line before output which appear automatically every time before output.
0 个评论
回答(2 个)
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);
0 个评论
Henrik
2014-10-17
Terminate the line with a semicolon:
sprintf('The array is %dx%d.',2,3);
2 个评论
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!