How to take an integer input from matalab file and put it in app designer as an enter box number ?

조회 수: 6 (최근 30일)
.

답변 (1개)

Jakob B. Nielsen
Jakob B. Nielsen 2020년 2월 4일
Lets call your app GUI.
First define a text box on the GUI;
TextEdit=uicontrol('Style','Edit','Units', 'normalized','string','YourNumber','Position',[0.02,0.84,0.05,0.02],'CallBack', @EditTextboxCallBack, 'HorizontalAlignment','center','visible','on','Parent', GUI);
%or 'Style','Text' instead of 'Style','Edit' if you dont want/need the user to change the number.
Then, lets say you have a matlab file named initdata, which contains just one integer. Load it, then set the edit box value to this integer.
myinteger=load('initdata.mat');
set(TextEdit, 'String', num2str(myinteger));
%If you need the user to be able to specify a different input, make a function with the same name as your CallBack in the uicontrol.
function EditTextboxCallBack(~,~)
myintegerstring = get(TextEdit,'String');
myinteger=str2num(myintegerstring);
end

카테고리

Help CenterFile Exchange에서 Package and Share Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by