How to stop display of variable type in command window?

조회 수: 9 (최근 30일)
David Winthrop
David Winthrop 2021년 11월 12일
편집: Jan 2021년 11월 13일
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
Walter Roberson
Walter Roberson 2021년 11월 12일
pi == pi
ans = logical
1
disp(pi == pi)
1
display(pi == pi)
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