Search code examples
matlabcommand-window

How can I format the command window output of a custom class in Matlab?


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?


Solution

  • 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.