开发者

How to check if value is valid property in Matlab?

Is there a way of checking whether a property value is valid for the given hobject? I took the 'enable' property below just as an example, my question is for general property, and assuming you don't know all the possible accepted properties values in advance.

% MyBtnObject is a standard push button

% this will be ok
set(MyBtnObject, 'enable', 'on'开发者_C百科);

% and this will not, but how can I check it?
set(MyBtnObject, 'enable', 'SomeInventedProp');


I've found the answer. I can use x = set(MyBtnObject, 'enable') to get the possible values to the enable property, listed as cell array x.

% find buttons
h = findobj('style', 'pushbutton');

% getting all the possible values for 'enable' property for all pushbuttons
% x = set(h, 'enable'), when h is array, will not work
x = arrayfun(@(x)(set(x, 'enable')), h, 'UniformOutput', false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜