How to stop display of variable type in command window?

5 次查看(过去 30 天)
Hello,
When I type
>> pi==pi
ans =
logical
1
I do not want to see the word "logical" there. How can I suppress this to make it as it was in the older versions?

回答(1 个)

Jan
Jan 2021-11-12
If you want the output as in old Matlab versions, you have to use old Matlab versions.
To control the output, use specific functions instead:
fprintf('%d', pi == pi)
1
  5 个评论
Jan
Jan 2021-11-13
编辑:Jan 2021-11-13
@David Winthrop: I understand, that you do not need this detail and that it clutters the ouptut. While using an old version is working, but a strange idea, the more important suggestion is not to rely on the automatically called display() if the semicolon is omitted after a command, but to produce te output explicitly.
Matlab's tries to be very smart without being intelligent. This cannot work reliably. The convention, that operations are applied alog the first non-singelton dimension is convenient, but a source of bugs: sum(X) without specifying the dimension save soe milliseconds during typing. But if this is hidden in the code and by accident X is not a 2D matrix, but a row vector, the result can differ from the expectations.
You struggle with an equivalent problem for the output to the command window. Relying on Matlab's guess about what you want does not satisfy you nor me. The output of my programs would suffer from such unneeded details also. Therefore I simply avoid them by using explicitly defined output functions in general.
You find many discussions in the forum about the troubles caused by using the convenient abbreviations offered by Matlab. If they impede your workflow, trying to tweak them such, that they work like you want might move the problem to another corner. I'd prefer the direct approach to write some code, which does exactly, what I want without smart guessing.
By the way, for a specific problem I'm running Matlab 5.3 run in a virtual machine, because it was ways faster for producing diagrams. For the actual computations it calls a modern Matlab version to reduce te processing time. Therefore my suggestion to use an old method if if satisfies your needs was not a joke.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by