How to put uigetfile data from Pushbutton into Listbox?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello Everyone,
Iam still new to GUI Logic of Matlab. I just want to get a logic code to set filename or uigetfile data into Listbox like this :
So, when the pushbutton contained with uigetfile code :
function loadekstrak_Callback(hObject, eventdata, handles)
% hObject handle to loadekstrak (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
push = guidata(gcbo);
[namafile,arah]=uigetfile({'*.txt', 'Text-Files (*.txt)'},'Load Data Magnet Format IAGA WDS (Definitif / Variatif)', 'Multiselect','on');
cd(arah);
full = fullfile(arah, namafile);
namafiles = cellstr(sort(namafile)); %Mensortir Kombinasi Data Yang Dipilih secara acak (PENTING)
fulls = string(full);
nfiles1 = size(full,2);
nfiles2 = numel(full);
f = cellstr(fullfile(arah,namafile));
file = length(f);
The callback function of listbox will add those information. And by using the code below, i am still get an error as the output :
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
list = guidata(gcbo);
index_selected = get(handle.push,'Value');
list = get(hObject,'String');
item_selected = list{index_selected}; % Convert from cell array
% to string
Iam just trying to get information of " namafile " (filename from uigetfile) or "full" variable to be set into the listbox once the pushbutton was clicked and the data was selected respectively....
So anyone, would you mind to help me to find a logic for the code? I just dont understand if iam just read from the documentation.....
Thank you very much everyone /.\ /.\ /.\
1 commentaire
Jan
le 18 Sep 2021
This part of the code does not do anything useful:
cd(arah);
full = fullfile(arah, namafile);
namafiles = cellstr(sort(namafile)); %Mensortir Kombinasi Data Yang Dipilih secara acak (PENTING)
fulls = string(full);
nfiles1 = size(full,2);
nfiles2 = numel(full);
f = cellstr(fullfile(arah,namafile));
file = length(f);
Réponse acceptée
Jan
le 18 Sep 2021
Modifié(e) : Jan
le 18 Sep 2021
I'm not sure what you want to achieve. With some guessing:
function loadekstrak_Callback(hObject, eventdata, handles)
% hObject handle to loadekstrak (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
push = guidata(gcbo);
[namafile,arah] = uigetfile({'*.txt', 'Text-Files (*.txt)'}, ...
'Load Data Magnet Format IAGA WDS (Definitif / Variatif)', ...
'Multiselect', 'on');
if isempty(namafile) % canceled
return;
end
push.listbox1.String = fullfile(ara, cellstr(namafile));
end
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!