GUI apps design for newbie
古いコメントを表示
Hello everyone,
I am new in using matlab, and unfamiliar with the programming language. Currently, I made a GUI using apps design that user need to insert 2 value and when click the pushbutton of CALCULATE; the value of TOTAL and MINIMUM and MAXIMUM value will automated calculate and appear. But sadly, I don't know what coding to insert in callback. Can someone help me, it seems easy but i really need someone's help because i am newbie in this field, sorry for any inconveniece. Here I paste the coding that I already generated from my developed GUI;
Thank you so much.

classdef Testing < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
CalculateButton matlab.ui.control.Button
CO2EditField matlab.ui.control.NumericEditField
CO2EditFieldLabel matlab.ui.control.Label
EditField_4 matlab.ui.control.NumericEditField
EditField_3 matlab.ui.control.NumericEditField
EditField_2 matlab.ui.control.NumericEditField
EditField matlab.ui.control.NumericEditField
MaximumLabel matlab.ui.control.Label
MinimumLabel matlab.ui.control.Label
TOTALLabel matlab.ui.control.Label
FabricationLabel matlab.ui.control.Label
MaterialLabel matlab.ui.control.Label
ParametersLabel matlab.ui.control.Label
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 ParametersLabel
app.ParametersLabel = uilabel(app.UIFigure);
app.ParametersLabel.HorizontalAlignment = 'center';
app.ParametersLabel.FontWeight = 'bold';
app.ParametersLabel.Position = [56 417 70 22];
app.ParametersLabel.Text = 'Parameters';
% Create MaterialLabel
app.MaterialLabel = uilabel(app.UIFigure);
app.MaterialLabel.HorizontalAlignment = 'center';
app.MaterialLabel.FontWeight = 'bold';
app.MaterialLabel.Position = [170 417 50 22];
app.MaterialLabel.Text = 'Material';
% Create FabricationLabel
app.FabricationLabel = uilabel(app.UIFigure);
app.FabricationLabel.HorizontalAlignment = 'center';
app.FabricationLabel.FontWeight = 'bold';
app.FabricationLabel.Position = [260 417 70 22];
app.FabricationLabel.Text = 'Fabrication';
% Create TOTALLabel
app.TOTALLabel = uilabel(app.UIFigure);
app.TOTALLabel.HorizontalAlignment = 'center';
app.TOTALLabel.FontWeight = 'bold';
app.TOTALLabel.Position = [364 417 44 22];
app.TOTALLabel.Text = 'TOTAL';
% Create MinimumLabel
app.MinimumLabel = uilabel(app.UIFigure);
app.MinimumLabel.HorizontalAlignment = 'center';
app.MinimumLabel.FontWeight = 'bold';
app.MinimumLabel.Position = [442 417 58 22];
app.MinimumLabel.Text = 'Minimum';
% Create MaximumLabel
app.MaximumLabel = uilabel(app.UIFigure);
app.MaximumLabel.HorizontalAlignment = 'center';
app.MaximumLabel.FontWeight = 'bold';
app.MaximumLabel.Position = [524 417 60 22];
app.MaximumLabel.Text = 'Maximum';
% Create EditField
app.EditField = uieditfield(app.UIFigure, 'numeric');
app.EditField.Position = [250 389 80 22];
% Create EditField_2
app.EditField_2 = uieditfield(app.UIFigure, 'numeric');
app.EditField_2.Position = [346 389 80 22];
% Create EditField_3
app.EditField_3 = uieditfield(app.UIFigure, 'numeric');
app.EditField_3.Position = [431 389 80 22];
% Create EditField_4
app.EditField_4 = uieditfield(app.UIFigure, 'numeric');
app.EditField_4.Position = [514 389 80 22];
% Create CO2EditFieldLabel
app.CO2EditFieldLabel = uilabel(app.UIFigure);
app.CO2EditFieldLabel.HorizontalAlignment = 'right';
app.CO2EditFieldLabel.Position = [82 389 30 22];
app.CO2EditFieldLabel.Text = 'CO2';
% Create CO2EditField
app.CO2EditField = uieditfield(app.UIFigure, 'numeric');
app.CO2EditField.Position = [156 389 80 22];
% Create CalculateButton
app.CalculateButton = uibutton(app.UIFigure, 'push');
app.CalculateButton.Position = [515 341 82 23];
app.CalculateButton.Text = 'Calculate';
% 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 = Testing
% 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
3 件のコメント
bo zhang
2024 年 2 月 22 日
In the design view, you can right click the CALCULATE button, and click 'callback' to create a callback function for this button.
Nurul Ainina
2024 年 2 月 22 日
Nurul Ainina
2024 年 2 月 22 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Fuzzy Logic Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!