Я использовал дизайнер приложений для создания слайдера и кнопки.Я хочу, чтобы люди использовали ползунок, чтобы обозначить свои мысли, а затем нажмите кнопку продолжения, чтобы продолжить эксперимент и, таким образом, закрыть окно ползунка.Значение ползунка необходимо сохранить в переменной, чтобы сохранить позже.Я не могу заставить закрытие окна работать.Не могли бы вы помочь мне?
classdef AppExampleTrackSlider < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
TrackSliderUIFigure matlab.ui.Figure
ContinueButton matlab.ui.control.Button
CompletelyOffTaskLabel matlab.ui.control.Label
CompletelyOnTaskLabel matlab.ui.control.Label
Label matlab.ui.control.Label
Slider_2 matlab.ui.control.Slider
end
methods (Access = private)
% Callback function
function SliderValueChanging(app, event)
% Get latest slider value
changingValue = event.Value;
end
% Button pushed function: ContinueButton
function ContinueButtonPushed(app, event)
TUT = changingValue;
disp('Button Pushed')
end
% Close request function: TrackSliderUIFigure
function TrackSliderUIFigureCloseRequest(app, event)
delete(app)
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create TrackSliderUIFigure
app.TrackSliderUIFigure = uifigure;
app.TrackSliderUIFigure.Position = [100 100 388 280];
app.TrackSliderUIFigure.Name = 'Track Slider';
% Create Slider_2
app.Slider_2 = uislider(app.TrackSliderUIFigure);
app.Slider_2.Limits = [1 4];
app.Slider_2.MajorTicks = [1 2 3 4];
app.Slider_2.Position = [43 132 303 3];
app.Slider_2.Value = 1;
% Create ContinueButton
app.ContinueButton = uibutton(app.TrackSliderUIFigure, 'push');
app.ContinueButton.ButtonPushedFcn = createCallbackFcn(app, @ContinueButtonPushed, true);
app.ContinueButton.Position = [150 27 100 22];
app.ContinueButton.Text = 'Continue';
% Create CompletelyOffTaskLabel
app.CompletelyOffTaskLabel = uilabel(app.TrackSliderUIFigure);
app.CompletelyOffTaskLabel.Position = [1 150 114 22];
app.CompletelyOffTaskLabel.Text = 'Completely Off Task';
% Create CompletelyOnTaskLabel
app.CompletelyOnTaskLabel = uilabel(app.TrackSliderUIFigure);
app.CompletelyOnTaskLabel.Position = [275 150 114 22];
app.CompletelyOnTaskLabel.Text = 'Completely On Task';
% Create Label
app.Label = uilabel(app.TrackSliderUIFigure);
app.Label.Position = [12 214 375 67];
app.Label.Text = {'Please indicate how much your thoughts were focused elsewhere'; 'than the task (Off Task) or focused on the task (On Task). Place the '; 'slider exactly above the integer chosen by you. '};
end
end
methods (Access = public)
% Construct app
function app = AppExampleTrackSlider
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.TrackSliderUIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.TrackSliderUIFigure)
end
end
end