How to stop display of variable type in command window?
3 次查看(过去 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?
0 个评论
回答(1 个)
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)
5 个评论
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 Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!