octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #49794] display vs. disp functions


From: Amro
Subject: [Octave-bug-tracker] [bug #49794] display vs. disp functions
Date: Fri, 9 Dec 2016 16:13:17 +0000 (UTC)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:45.9) Gecko/20100101 Goanna/3.0 Firefox/45.9 PaleMoon/27.0.2

Follow-up Comment #3, bug #49794 (project octave):

Right, sorry for not being precise.

Basically "display" only shows the variable name if the input is an existing
variable, no name is printed for expressions (not even "ans" as I mistakenly
stated before). This is of course followed by the actual value.

Here's a doc page that further describes disp vs. display:
https://www.mathworks.com/help/matlab/matlab_oop/displaying-objects-in-the-command-window.html

Here are some examples in MATLAB to show the different cases:


>> 1+1
ans =
     2
>> disp(1+1)
     2
>> display(1+1)
     2



>> x=1+1
x =
     2
>> disp(x)
     2
>> display(x)
x =
     2



>> 2
ans =
     2
>> disp(2)
     2
>> display(2)
     2


Note: I use "format compact" by default in MATLAB. This tends to produce less
blank lines as opposed to "format loose". Now Octave have both these format
settings, but it doesn't seem to have an effect on the output, and seems to
always use the compact form. I wanna keep the bug report focused on one issue,
so I'm not too concerned about this aspect here :)

Finally note that "display" in MATLAB has a second *undocumented* input, it
can be used to override the variable name printed. Example:


>> display(1+1, 'myvar')
myvar =
     2
>> display(2, 'myvar')
myvar =
     2
>> display(x, 'myvar')
myvar =
     2



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?49794>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]