Load Button GUI trouble

조회 수: 3 (최근 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 CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by