Load Button GUI trouble
1 view (last 30 days)
Show older comments
I am using GUIDE, but I cannot reconcile how to get the push button "Load Data" to bring a "browse" window up. How to do it with using this code as a start?
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
0 Comments
Accepted Answer
Evan
on 3 Jul 2013
Edited: Evan
on 3 Jul 2013
help uigetfile
Put uigetfile in the callback of your pushbutton (the code you copy+pasted here). For info on how to specify outputs, limit your search to certain filetypes/directories, etc., read the help page for uigetfile.
4 Comments
Evan
on 8 Jul 2013
Assuming your text file is three simply columns divided by spaces and nothing else (e.g. no text to remove), the following code should be a good starting point to help you load it in:
[filename,pathname] = uigetfile('*.txt')
fullpath = fullfile(pathname,filename);
fid = fopen(fullpath);
t = textscan(fid,'%d %d %d');
That will load in your data as a 1x3 cell array. Each cell will be a column. All you have to do then is access each cell and plot the data on your axes.
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!