4

how can I achieve a formatted output in the command-window in Matlab when I call the object ob a custom class? The regular output of a custom class is a list of all public properties as shown below.

customss with properties:

    A: [8×8 double]
    B: [8×1 double]
    C: [2×8 double]
    D: [2×1 double]

For example, when I create a state space model in Matlab and then call the object in the command window the output is a formatted representation of the system matrices and the sample time. Even by debugging I could not figure out if possibly a certain function is call to achieve this. So, how can I create such an customized output?

Marcel
  • 43
  • 3

1 Answers1

3

MATLAB has a special abstract class matlab.mixin.CustomDisplay which your class can inherit to make the display behaviour customizable.

MathWorks has a detailed documentation section covering various customizations this allows.

Will
  • 1,835
  • 10
  • 21
  • I don't have the Control System Toolbox to check myself, but it may be that the built in `ssm` class uses this method directly for its display format. If so, you could inspect this using `edit ssm`, or maybe specifically `edit ssm.displayPropertyGroups` to see how to match the behaviour exactly in your custom state space class. – Will Nov 02 '18 at 12:33