GUI-import and process multiple files
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I've created two radio buttons. I want to make that only one file is imported when one button is selected and multiple files are imported when the other button (handles.rbmultiple) is selected. Right now I was able to import one file, update axes, and fit different sections of the curve (shown in the video: https://goo.gl/7ny46h ). But I don't really know how to import multiple files, plot the curves on the same graph, and do the fitting. I got errors after adding the for loop. Any help will be highly appreciated! The full code can be found here: https://github.com/dupypy/MechanicalGUI/blob/master/gui.m
Part of the code is
plotstyle = get(handles.rbmultiple, 'value');
if plotstyle
[filenames] = uigetfile('*.csv','MultiSelect','on');
numfiles = size(filenames,2);
for k = 1:numfiles
handles.filename = filenames(k);
handles.filename
guidata(hObject, handles);
setPopupMenuString(handles.popupmenuX, eventdata, handles); % custom function
setPopupMenuString(handles.popupmenuY, eventdata, handles); % custom function
set(handles.popupmenuX, 'callback', 'gui(''updateAxes'',gcbo, [], guidata(gcbo))');
set(handles.popupmenuY, 'callback', 'gui(''updateAxes'',gcbo, [], guidata(gcbo))');
end
else
handles.filename = uigetfile('*.csv');
guidata(hObject, handles);
setPopupMenuString(handles.popupmenuX, eventdata, handles); % custom function
setPopupMenuString(handles.popupmenuY, eventdata, handles); % custom function
set(handles.popupmenuX, 'callback', 'gui(''updateAxes'',gcbo, [], guidata(gcbo))');
set(handles.popupmenuY, 'callback', 'gui(''updateAxes'',gcbo, [], guidata(gcbo))');
end
0 Commenti
Risposte (1)
Jan
il 31 Mar 2017
Modificato: Jan
il 31 Mar 2017
filenames is a cell string, such that you need curly braces to get a single file name.
Using the path name is more convenient and safer.
[filenames, pathname] = uigetfile('*.csv','MultiSelect','on');
numfiles = size(filenames, 2);
for k = 1:numfiles
handles.filename = fullfile(pathname, filenames{k});
...
Whenever you mention in the forum, that you get an error message, add a complete copy of the message. It is easier to suggest a solution than to guess the problem and you have the required details on your screen already.
The contents of the loop performs the same commands in each iteration. I assume you want to apply some settings, which depend on the filename?
2 Commenti
Vedere anche
Categorie
Scopri di più su Annotations 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!