Back to old display format in Matlab R2016b

In Matlab R2016b, displaying variables of specific data types shows type information. This happens when a variable is displayed, entering it without a final semicolon (this does not happen when using the disp function).

Compare, for example:

  • Matlab R2015b (old format: only displays data):

     >> x = [10 20 30] x = 10 20 30 >> x = {10 20 30} x = [10] [20] [30] >> x = [false false true] x = 0 0 1 
  • Matlab R2016b (new format: includes type):

     >> x = [10 20 30] x = 10 20 30 >> x = {10 20 30} x = 1Γ—3 cell array [10] [20] [30] >> x = [false false true] x = 1Γ—3 logical array 0 0 1 

As you can see, R2016b contains an extra line indicating the type. Apparently this happens for any type that is not double or char .

Is there any tweak in R2016b to revert to the old behavior?

+5
source share
1 answer

Unfortunately, this behavior seems to have no preference. There is (as always) a bit of a hacker workaround.

When you omit a semicolon from a string, it is not called disp , but rather display . R2016b apparently modified the display method for the cell data type to display type information along with the values ​​themselves.

Fortunately, we can overload this display method with something that is a bit like the display previous releases.

We can create the @cell folder (anywhere on our path) and put the file named display.m inside.

@cell/display.m

 function display(obj) % Overloaded display function for grumpy old men if strcmpi(get(0, 'FormatSpacing'), 'loose') fprintf('\n%s =\n\n', inputname(1)) else fprintf('%s =\n', inputname(1)) end disp(obj); end 

Now, whenever a cell array is displayed due to the lack of a finite semi-colony, it will not include type information.

 >> c = {'a', 'b'} c = 'a' 'b' 

Unfortunately, there are other data types (e.g. logical ) that also display type information, so you have to overload the display method for each of these classes.

+3
source

Source: https://habr.com/ru/post/1257636/


All Articles