我想将文本文件中的数据加载到弹出菜单中:
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
str=['path\list.txt'];
fileID = fopen (str,'r');
C = textscan(fileID,'%d %s','Delimiter',' ');
for i = 1:length(C)
set(hObject,'String',{cellstr(C{2}(i))});
end
fclose(fileID);
但是我收到了这个错误:
使用matlab.ui.control.UIControl / set
时出错 在设置' String' UIControl的财产:
输入到String属性的单元格数组可能只包含字符和数字矩阵。conceptsCharge>出现错误popupmenu1_CreateFcn(第100行) 集(hObject,'字符串' {cellstr(C {2}(I))});
gui_mainfcn出错(第95行) feval(varargin {:});
conceptsCharge(第42行)出错 gui_mainfcn(gui_State,varargin {:});
@(hObject,eventdata)conceptsCharge(' popupmenu1_CreateFcn',hObject,eventdata,guidata(hObject))
单元格C看起来像这样: