bugGNU Octave - Bugs: bug #49979, format compact/loose different...


bug #49979: format compact/loose different from Matlab

Submitted by:  Rik <rik5>
Submitted on:  Tue 03 Jan 2017 04:49:22 PM UTC  
Category:  Interpreter Severity:  1 - Wish
Priority:  1 - Later Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 05 Jan 2017 06:39:36 PM UTC, comment #5:

I think jwe's suggestion is reasonable. If anyone wants 100% visual compatibility with Matlab they can write their own display routines to do so.

For comment #3, bug #49794 was fixed by jwe. I just closed bug #33383 because it was in turn resolved by the cset for #49794.

To anyone who comes later, I have changed the Severity to Wish and the Priority to Later. We can review any changesets that people have, but the core developers aren't going to work on it.

Rik <rik5>
Project Administrator
Thu 05 Jan 2017 06:18:37 PM UTC, comment #4:

If the output format changed, it wasn't intentional.

I agree that each element of a struct or cell should be formatted independently of context. I really don't want to have the function that displays the contents of a matrix checking to see whether it is called in the context of displaying a cell or struct or some other object and doing special things because of that.

Meta comment: I find it a little crazy that people seem to care about this issue and expect that Octave displays all output exactly as Matlab does. But whatever, we could certainly have an option. Or, now it should be possible for you to write your own @cell/display.m and @cell/disp.m functions to do whatever you want.

John W. Eaton <jwe>
Project Administrator
Thu 05 Jan 2017 05:57:27 PM UTC, comment #3:

I prefer Octave's cell array output by default, showing the contents. This is similar to the intentional difference in struct arrays (configurable with struct_levels_to_print).

If people want truly compatible output, maybe there could be a similar configuration option, cell_contents_display, that could be set with the --traditional command line option.

The major drawback with Octave's approach is bug #33383. Octave's core should be in charge of how the cell array is formatted (whether it shows indices in brackets or not, whether it shows a value in brackets or not, or whether it just shows a dimension), and each element should be in charge of only how its value is displayed. That may have changed with bug #49794, I haven't been following developments in the past month or so.

Mike Miller <mtmiller>
Project Administrator
Thu 05 Jan 2017 05:34:16 PM UTC, comment #2:

Thanks for checking in Matlab. Should we make it a goal of Octave to move to the Matlab method of displaying cell arrays? Or is what we have good enough?

Rik <rik5>
Project Administrator
Thu 05 Jan 2017 10:26:43 AM UTC, comment #1:

For Matlab R2016b I get:



Cell arrays

I think Octave and Matlab produce reasonable output. For your last example, Matlab chooses a more pragmatic approach to avoid too verbose output. Maybe we can also adapt this for matrices? For scalars one gets in Matlab the values (as `1x1 double` is less informative than printing out the value itself):

Kai Torben Ohlhus <siko1056>
Project Member
Tue 03 Jan 2017 04:49:22 PM UTC, original submission:

There are a number of differences in the display of variables between Matlab and Octave related to the compact/loose option to format.

The first, which I don't think we should change, is the the universal presence of a newline after the name of the variable in Matlab. Under Octave, the interpreter makes a decision about how large the display of the variable will be and if it is short, it puts it all on one line. I like that.

For instructional purposes, here are the documented Matlab display of the same variable under compact/loose


Under Octave with either format

The question is how to display something more complicated, like a matrix, under the two different formats. This is the result under 4.2.0

The difference is a newline before and after the matrix. However, there is no newline before the name of the variable "x =" as there is in Matlab under format loose to help separate the interpreter command from the display. Maybe that is worth changing?

A second possible change is that the newline is always inserted after the matrix object, when for cells it should be after the cell braces which mark the start and end of the object.

An example is

Again, just a question, but maybe it would make more sense to remove the newline before the final '}' and place it after the '}' so there was some space before the start of the next interpreter command prompt. Someone could also check under Matlab and see how it treats these examples.

Rik <rik5>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-01-05 rik5 Severity2 - Minor => 1 - Wish
        Priority5 - Normal => 1 - Later

    Back to the top

    Powered by Savane 3.3