Filter löschen
Filter löschen

Load Button GUI trouble

1 Ansicht (letzte 30 Tage)
James Hendren
James Hendren am 3 Jul. 2013
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)

Akzeptierte Antwort

Evan
Evan am 3 Jul. 2013
Bearbeitet: Evan am 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 Kommentare
James Hendren
James Hendren am 5 Jul. 2013
here's what I am trying to do. My gui has two graphs side by side and I am trying to load data on both graphs. The text file has 3 columns. The 1st is wavelength. Then the second is a psi value and the third is a delta. The first column would be the x-axis for both graphs. Then the the second column would be the first graph's y axis, and the third column would be the second graphs y axis. So could you offer some code to assist with this please?
Evan
Evan am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by