- Inherit from matlab.mixin.CustomDisplay: Ensure that your superclass (the one that inherits from matlab.mixin.Heterogeneous) also inherits from matlab.mixin.CustomDisplay.
- Override Display Methods: Override the relevant methods from matlab.mixin.CustomDisplay to control the display of your objects.
Custom/Correction of Workspace display value for heterogeneous array
2 次查看(过去 30 天)
显示 更早的评论
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>
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/926959/image.png)
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.
0 个评论
回答(1 个)
arushi
2024-1-24
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:
Please refer to the documentation of the “CustomDisplay” function –
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Customize Object Display for Classes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!