Memo/Matlab

Matlab : UI drop-down

_Ju 2022. 8. 1. 22:25

 

This is about 'UI Drop-down'

 


#List Change

%// I recommend to make the first DD menu be a blank.
%// (Matlab does not recognize the selected DD list index as the menu is changed)
%// (Therefore, i should induce the user to reselect.)
DropDownList1 = {'', 'A_Menu_1', 'A_Menu_2', 'A_Menu_3'};
DropDownList2 = ["", "B_Menu_1", "B_Menu_2", "B_Menu_3"];

TaskOrder = 'Work_A';
if (strcmp(TaskOrder, 'Work_A'))
	app.DropDown.Items = DropDownList1;
elseif (strcmp(TaskOrder, 'Work_B'))
	app.DropDown.Items = DropDownList2;
end

#Proceed according to the selected D.D. menu

if (strcmp(TaskOrder, 'Work_A'))
    if (strcmp(app.DropDown.Value, DropDownList1(2)))
        disp('A_Menu_1');
    elseif (strmp(app.DropDown.Value, DropDownList1(3)))
        disp('A_Menu_2');
    elseif (strmp(app.DropDown.Value, DropDownList1(4)))
        disp('A_Menu_3');
    end
elseif (strcmp(TaskOrder, 'Work_B'))
    if (strcmp(app.DropDown.Value, DropDownList2(2)))
        disp('B_Menu_1');
    elseif (strmp(app.DropDown.Value, DropDownList2(3)))
        disp('B_Menu_2');
    elseif (strmp(app.DropDown.Value, DropDownList2(4)))
        disp('B_Menu_3');
    end
end

 

#Matlab

#Matlab App Designer