How to stop display of variable type in command window?

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)

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

Bummer. That really should be an option! Sometimes "improvements" are not so much.
FYI this change was made over five years ago as part of release R2016b. Did you upgrade recently from a release older than that (and so were just exposed to the change)? If not may I ask what prompted you to ask if it was possible to suppress that display?
It has bothered me for years and I always thought some day I'd figure out how to suppress it. Today was the day I really tried. What was the thinking behind not allowing this as an option? I find it very cluttery and completely unnecessary. As in, there is no reason whatsoever for MATLAB to tell me variable type because I always have the workspace window wich displays these and functions such as whos.
pi == pi
ans = logical
1
disp(pi == pi)
1
display(pi == pi)
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 Programming in Help Center and File Exchange

Products

Release

R2018b

Tags

Asked:

on 12 Nov 2021

Edited:

Jan
on 13 Nov 2021

Community Treasure Hunt

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

Start Hunting!