Clear Filters
Clear Filters

Custom/Correction of Workspace display value for heterogeneous array

1 view (last 30 days)
Hi,
I've been inheriting matlab.mixin.Heterogeneous for one of my superclasses to enable arrays of multiple subclasses together. This is all works great and behaves as expected when working in the command window/files/etc; however, in the workspace the value of the variable of the nonscalar heterogeneous array says:
<Error Displaying Value>
I looked into matlab.mixin.CustomDisplay but I was unable to determine if I was able to utilize it to correct/edit that erroneous display. I found some undocumented Matlab about accessing the Java behind the workspace to change some values (like Byte display information for instance) but that seemed unncesarily complicated and possibly outdated since it was from 2010.
I couldn't find any helpful documentation on this issue or very many people asking about this in this context. If anyone has any ideas, that would be greatly appreciative.

Answers (1)

arushi
arushi on 24 Jan 2024
Hi Justin,
I understand that you are facing this error of displaying error value while working with heterogeneous array. When you use matlab.mixin.Heterogeneous to create arrays of objects from different classes in MATLAB, you should normally be able to see a summary of the array in the workspace. However, if you're seeing <Error Displaying Value> in the workspace, it suggests there might be an issue with how the display is being handled for the heterogeneous array.
matlab.mixin.CustomDisplay is indeed the right direction to look into for customizing how your objects are displayed in MATLAB. This class allows you to control various aspects of the display, including what happens when an array of objects is displayed in the workspace.
Here's a brief outline of how you might use matlab.mixin.CustomDisplay to address the display issue:
  1. Inherit from matlab.mixin.CustomDisplay: Ensure that your superclass (the one that inherits from matlab.mixin.Heterogeneous) also inherits from matlab.mixin.CustomDisplay.
  2. Override Display Methods: Override the relevant methods from matlab.mixin.CustomDisplay to control the display of your objects.
Please refer to the documentation of the “CustomDisplay” function –
Hope this helps.

Categories

Find more on Customize Object Display for Classes in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!