Whos function in gui
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
JEONGSOO BAE
am 14 Aug. 2017
Beantwortet: Guillaume
am 14 Aug. 2017
Hello. I successfully load .mat files into a listbox. I also defined another listbox, but I want to display the variables inside of the file in another listbox.
function LoadedFiles_Callback(hObject, eventdata, handles)
contents = cellstr(get(hObject,'String'));
chosefile = contents{get(hObject,'Value')};
set(handles.endlist, 'String', whos(chosefile));
function Load_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile( ...
{'*.mat','MAT-files (*.mat)'}, 'Pick .m data files', 'MultiSelect', 'on');
thefile=fullfile(pathname,filename);
set(handles.LoadedFiles,'String',thefile);
So second Load_Callback function works as intended. However, the first block of function generates error. Can anyone help with this? Thank you!
0 Kommentare
Akzeptierte Antwort
Guillaume
am 14 Aug. 2017
"the first block of function generates error". And we are supposed to guess what the error is? When you get an error always post the full error message.
Possibly the problem is the way you call whos. If you're giving it the name of a mat file, you need to tell whos that it is a file with the syntax:
whos('-file', chosefile)
Or possibly the problem is that you're assuming that the output of whos is a cell array of strings whereas it is a structure with several fields, so maybe:
vars = whos('-file', chosefile');
set(handles.endlist, 'String', {vars.name});
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!