필터 지우기
필터 지우기

input the default value in an edit box of a GUI as an input from a file?

조회 수: 1 (최근 30일)
Nidhi SRIVASTAVA
Nidhi SRIVASTAVA 2017년 7월 4일
댓글: Jan 2017년 7월 4일
Is there a way to input the default value in an edit box of a GUI as an input from a file? I have a file with data (file attached)
I want to input the values row by row into edit boxes of a GUI. ex: EditBox1 as: H V1 V2 RHO Edit2 as:2 500 205. 2.78 Edit3 as:4 600 288. 3.0 I can't figure out how to set default of a edit box as input from a file. Can anybody please help me with it? Thanks.

답변 (1개)

Jan
Jan 2017년 7월 4일
Import the file in the OpeningFcn of the GUI (if you have created it by GUIDE). Then you can populate the edit boxes with the values, which appear initially.
If you attach the file, does it mean that the import of the file is a part of the problem? If so, please explain this explicitely.
  댓글 수: 2
Nidhi SRIVASTAVA
Nidhi SRIVASTAVA 2017년 7월 4일
Hi Jan. Thank you for the direction. I didn't import the file earlier. But it surely seems to be a nice approach. Now that I imported the file, what should I add to the callback(hObject, eventdata, handles)? I tried: In OpeningFcn: A=importdata(file)
setappdata(0,'evalue1',A.colheaders);
In callback: A.colheaders = getappdata(0,'evalue1'); set(handles.edit1,'String',A.colheaders)
Please suggest me the changes.
Jan
Jan 2017년 7월 4일
Why do you set the ApplicationData of the root object? Which callback do you mean here? I'd suggest:
function OpeningFcn(...)
A = importdata(file);
set(handles.edit1, 'String', A.colheaders);
...
If there is a need to store the data, store them locally:
FigH = ancestor(hObject, 'figure');
setappdata(FigH, 'FileData', A); % Or getappdata

댓글을 달려면 로그인하십시오.

카테고리

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