Change value of a dropDown menu containing objects of different classes

8 views (last 30 days)
Hello dear community,
I have implemented various DropDown elements in my Matlab app. One of my DropDown elements have objects of different classes available for selection. However, all objects have the same superclass and inherit the overloaded comparison operator. This operator uses the name, an attribute of the objects, to compare them.
If I change the selected object of the DropDown element, Matlab finds the correct entry in the ItemsData of the DropDown element and does not throw me any errors. But if I now want to change the value of the DropDown element via code and write for example:
app.(name_dropDown).Value = test_object;
I get the error message that test_object is not part of the ItemsData. The problem is apparently that ItemsData is a cellarray, since this contains various objects of various subclasses, and Matlab wants to validate test_object via the ismember function, then ends up in the catch block and uses isequal in combination with cellfun. Apparently, the isequal function does not call the overloaded comparison operator. If this would be called the whole thing would work.
Does anyone have an idea how I can cleverly solve this?
Thanks a lot!

Answers (0)


Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by