0
我想在Matlab GUI的彈出式菜單中獲取所選項目的索引。爲此,我寫了這個在彈出的回調函數:在Matlab彈出菜單中返回所選項目的索引
contents = cellstr(get(h0bject,'String'));
theItem = contents{get(h0bject,'Value')};
theindex = find(contents == theItem);
Matlab的返回:
Undefined function 'eq' for input arguments of type 'cell'
然後我寫了
contents = cellstr(get(h0bject,'String'));
theItem = contents{get(h0bject,'Value')};
contents = cell2mat(contents):
theItem = str2num(theItem);
theindex = find(contents == theItem);
Matlab的返回
index = Empty matrix: 0-by-1
可以肯定theItem
在contents
。我如何獲得索引?我在哪裏做錯了?
是的,後來我找到了解決方案。無論如何,非常感謝。 – newzad