How to stop display of variable type in command window?

15 views (last 30 days)
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?

Answers (1)

Jan
Jan on 12 Nov 2021
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 Comments
Jan
Jan on 13 Nov 2021
Edited: Jan on 13 Nov 2021
@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.

Sign in to comment.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!