Hi there
I wonder if someone can help me with this as I am new to Matlab. I have created a gui in matlab using guide and have added a popup button but I want the popup menu contents to vary based on a list created stored in a string. e.g. I have a file called ci which contains 'data', 'door', 'mug' in a list. I want this to be used in the popup menu. This list will vary so i need it to be dynamic so if the list also includes 'phone' etc it still works. Can anyone help? The code is given below
% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu4
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end
Best Answer