How to put uigetfile data from Pushbutton into Listbox?

1 visualizzazione (ultimi 30 giorni)
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 Commento
Jan
Jan il 18 Set 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);

Accedi per commentare.

Risposta accettata

Jan
Jan il 18 Set 2021
Modificato: Jan il 18 Set 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 Commento
Tyann Hardyn
Tyann Hardyn il 18 Set 2021
Modificato: Tyann Hardyn il 18 Set 2021
Omg, you did it, that was Great. I just want to get the logic of GUI' code, and i know it by now....
Thank you so much, Sir Jans..
Actually, I want to show some loading file (from selected files) which want to be proceeded at my program in that listbox....

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by