How can i get value from field that created by uideditfiled command ?

조회 수: 10 (최근 30일)
TARIK YAMAN
TARIK YAMAN 2021년 3월 14일
댓글: Sri Vishnu Katreddi 2022년 7월 12일
Hi. I m new matlab app designer app. I create a numeric field and i ask input from user then i created automatically numeric field according to user input. (figure 2). How i can read values that where in created fields ?
Also, is there any different methods for creation fields automatically and adding as components.
classdef app8 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
NumEditFieldLabel matlab.ui.control.Label
NumEditField matlab.ui.control.NumericEditField
Button matlab.ui.control.Button
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button
%% %% %% %% %% %% %% %% %% %% %% !!!!!!
function ButtonPushed(app, event)
for i = 1:app.NumEditField.Value
eval(sprintf('app8.ef%d = uieditfield(app.UIFigure,"numeric")',i));
eval(sprintf('app8.ef%d.Position = [180,350 - %d,31,22]',i,37*i))
end
end
%% %% %% %% %% %% %% %% %% %% %% !!!!!!
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'MATLAB App';
% Create NumEditFieldLabel
app.NumEditFieldLabel = uilabel(app.UIFigure);
app.NumEditFieldLabel.HorizontalAlignment = 'right';
app.NumEditFieldLabel.Position = [86 413 31 22];
app.NumEditFieldLabel.Text = 'Num';
% Create NumEditField
app.NumEditField = uieditfield(app.UIFigure, 'numeric');
app.NumEditField.Position = [132 413 100 22];
% Create Button
app.Button = uibutton(app.UIFigure, 'push');
app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
app.Button.Position = [132 362 100 22];
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = app8
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end

답변 (1개)

Cameron B
Cameron B 2021년 3월 15일
Are you just trying to get the value of the input from the user? If so then it's
YourNum = app.NumEditField.Value

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by