Memo/Matlab

Matlab function : Change the Enable of several UIs

_Ju 2022. 8. 9. 21:14

When you want to change the enable of several UIs,

You can use this function.

 


#Function

%// how to call function
TargetUIs = [app.TextArea, app.EditField, app.Label];
EnablChanger('off', TargetUIs);
EnablChanger('on', TargetUIs);



%// Below is the function
function EnablChanger(Task, TargetUIs);
	CountList = length(TargetUIs);
    for i = 1 : CountList
    	if (strcmp(Task, 'on'))
        	TargetUIs(i).Enable = 'on';
        elseif  (strcmp(Task, 'off'))
        	TargetUIs(i).Enable = 'off';
        end
    end
end