MATLAB: Add new DropDown item in App designer 2019a

app designerdropdown

Im new in Matlab, and Im trying to add a new item to the existing dropdown items, from an EditField text value, but I havent find out how, this is what Im doing, but Im not sure how to finish it:
function EditFieldValueChanged(app, event)
new = app.EditField.Value;
hDropDown = app.DropDown;
currentItems = get(hDropDown);
[~, index] = ismember(hDropDown.Value, hDropDown.Items);
newItems = {currentItems,new};
newItems(index) = [];
end

Best Answer

This will add the edit text's string to the drop down's list of items as long as it is not already there:
function EditFieldValueChanged(app, ~)
new = app.EditField.Value;
if ~any(ismember(app.DropDown.Items, new))
app.DropDown.Items = [app.DropDown.Items new];
end
end
Is this what you're looking for?