Problem with value property of uidropdown
Hi,
I’m using a uidropdown control with the Items and ItemsData properties set within the method startupFcn of my app. I’m using the following simple code to specify the items of the dropdown control along with numeric IDs:
app.MethodDropDown.Items = Methods.TYPES(:, 1);
app.MethodDropDown.ItemsData = [Methods.TYPES{:, 2}];
Methods.Types is a cell-array in class Methods with the first column containing character arrays (i.e. the names for the method types) and the second column contains numeric ID values for the method types.
When retrieving the value of the selected item I observe a different behavior between different MATLAB versions. Up to 2022b the Value property returns the numeric value of the selected item as specified in ItemsData. However, starting with 2023a, a string (i.e. in my case a character array) is returned.
Am I doing something wrong? I suspect that something changed between 2022b and 2023a but I can’t find anything about such a change in the changelog of MATLAB. Moreover, the documentation of 2023a still states that my code seems to be correct.
Best,
MichaelHi,
I’m using a uidropdown control with the Items and ItemsData properties set within the method startupFcn of my app. I’m using the following simple code to specify the items of the dropdown control along with numeric IDs:
app.MethodDropDown.Items = Methods.TYPES(:, 1);
app.MethodDropDown.ItemsData = [Methods.TYPES{:, 2}];
Methods.Types is a cell-array in class Methods with the first column containing character arrays (i.e. the names for the method types) and the second column contains numeric ID values for the method types.
When retrieving the value of the selected item I observe a different behavior between different MATLAB versions. Up to 2022b the Value property returns the numeric value of the selected item as specified in ItemsData. However, starting with 2023a, a string (i.e. in my case a character array) is returned.
Am I doing something wrong? I suspect that something changed between 2022b and 2023a but I can’t find anything about such a change in the changelog of MATLAB. Moreover, the documentation of 2023a still states that my code seems to be correct.
Best,
Michael Hi,
I’m using a uidropdown control with the Items and ItemsData properties set within the method startupFcn of my app. I’m using the following simple code to specify the items of the dropdown control along with numeric IDs:
app.MethodDropDown.Items = Methods.TYPES(:, 1);
app.MethodDropDown.ItemsData = [Methods.TYPES{:, 2}];
Methods.Types is a cell-array in class Methods with the first column containing character arrays (i.e. the names for the method types) and the second column contains numeric ID values for the method types.
When retrieving the value of the selected item I observe a different behavior between different MATLAB versions. Up to 2022b the Value property returns the numeric value of the selected item as specified in ItemsData. However, starting with 2023a, a string (i.e. in my case a character array) is returned.
Am I doing something wrong? I suspect that something changed between 2022b and 2023a but I can’t find anything about such a change in the changelog of MATLAB. Moreover, the documentation of 2023a still states that my code seems to be correct.
Best,
Michael uidropdown, value, items, itemsdata MATLAB Answers — New Questions