Load Button GUI trouble

6 ビュー (過去 30 日間)
James Hendren
James Hendren 2013 年 7 月 3 日
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)

採用された回答

Evan
Evan 2013 年 7 月 3 日
編集済み: Evan 2013 年 7 月 3 日
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 件のコメント
James Hendren
James Hendren 2013 年 7 月 5 日
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 2013 年 7 月 8 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by