GUI-import and process multiple files
조회 수: 9 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Jan
2017년 3월 31일
편집: Jan
2017년 3월 31일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!