2013-12-14 39 views
2

我知道這個錯誤是在popupmenu初始化一個空列表時引起的,但是我有幾個popupmenu,如何知道彈出菜單的標籤會產生這個錯誤? 或者有辦法停止生成此警告?Matlab - 警告:popupmenu控件需要一個非空字符串

感謝

+2

這是一個警告,不是錯誤,對吧?看看[如何抑制警告](http://www.mathworks.de/de/help/matlab/matlab_prog/suppress-warnings.html) – thewaywewalk

回答

2

如果您使用的是結構化的陣列,如handles與使用MATLAB指南或您自己的結構數組的,這可以通過尋找組件的雙重價值處理和匹配的字段名的工作該結構通過在腳本或命令行中調用您的結構(取決於工作空間)。

components = findall(figure_handle,'Style','Popupmenu'); % returns double value for each handle 
menu_strings = get(components,'String'); % gets the string of each popupmenu 
indx = find(strcmpi(menu_strings,'')); % returns the position in the array of the empty components 
wanted_components = components(indx) % returns the double value of the components that have an empty string 

此外,您還可以使用Tag財產,如果你在標籤設置,你可以再添加:

get(wanted_components,'Tag') 

查看文檔find alltag property