GUI use of ListBox error:??? Attempt to reference field of non-structure array.
1 回表示 (過去 30 日間)
古いコメントを表示
Emanuele Gandola
2015 年 10 月 6 日
コメント済み: Emanuele Gandola
2015 年 10 月 6 日
Hallo!
I used GUIDE to build a simple GUI in Matlab.
I'd like to upload multiple images with this function linked to a push button
-
% --- Executes on button press in upload.
function upload_Callback(hObject, eventdata, handles)
[filename, foldername] = uigetfile({'*.*'}, 'Select file');
[handles.filename, handles.pathname] = uigetfile({'*.jpg'},'Select file','MultiSelect');
if
handles.filename ~= 0
handles.FileName = fullfile(handles.pathname, handles.filename);
end
-
and store all images in a ListBox first to execute them toghether.
The code into the list box is:
-
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
prev_list = get(handles.listbox1,'string')
vars = get(handles.upload.filename , 'Value');% new item form upload
display(vars);
new_list = [prev_list , vars ]
set(handles.listbox1,'string',new_list);
-
On the command get, when I try to create the new variable vars appear this error
-
??? Attempt to reference field of non-structure array.
Error in ==> interfaccia>listbox1_Callback at 94
vars = get(handles.upload.filename , 'Value');% new item form upload
-
What is my mistake?
Thank you in advance for your support.
Emanuele
0 件のコメント
採用された回答
Walter Roberson
2015 年 10 月 6 日
function upload_Callback(hObject, eventdata, handles)
[filenamesCell, pathname] = uigetfile({'*.jpg'},'Select file(s)','MultiSelect');
if ~isnumeric(filenamesCell)
oldlist = cellstr( get(handles.listbox1, 'String') );
set(handles.listbox1, 'String', [oldlist; fullfile(pathname, filenamesCell)]);
end
function listbox1_Callback(hObject, eventdata, handles)
choices = cellstr( get(hObject, 'String') );
idx_chosen = get(hObject, 'Value');
if ~isempty(idx_chosen)
chosen_file = choices{idx_chosen);
do something with chosen_file
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!