This is my function
classdef KOPDOC_exported < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Asphalt matlab.ui.control.UIAxes
RunKOPDOCButton matlab.ui.control.Button
CLTitle matlab.ui.control.Label
CLocation matlab.ui.control.EditField
CPTitle matlab.ui.control.Label
CPercentage matlab.ui.control.EditField
PLTitle matlab.ui.control.Label
PLocation matlab.ui.control.EditField
PPTitle matlab.ui.control.Label
PPercentage matlab.ui.control.EditField
DLTitle matlab.ui.control.Label
DLocation matlab.ui.control.EditField
DPTitle matlab.ui.control.Label
DPercentage matlab.ui.control.EditField
CracksLabel matlab.ui.control.Label
PotholesLabel matlab.ui.control.Label
DeliminationLabel matlab.ui.control.Label
ROADREPLACEMENTANALYSISLabel matlab.ui.control.Label
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: RunKOPDOCButton
function RunKOPDOCButtonPushed(~, ~)
end
% Value changed function: CLocation
function CLocationValueChanged(app, ~)
value = app.CLocation.Value;
end
% Value changed function: CPercentage
function CPercentageValueChanged(app, ~)
value = app.CPercentage.Value;
end
% Value changed function: PLocation
function PLocationValueChanged(app, ~)
value = app.PLocation.Value;
end
% Value changed function: PPercentage
function PPercentageValueChanged(app, ~)
value = app.PPercentage.Value;
end
% Callback function
function EditField_4ValueChanging(~, event)
changingValue = event.Value;
end
% Value changed function: DLocation
function DLocationValueChanged(app, ~)
value = app.DLocation.Value;
end
% Value changed function: DPercentage
function DPercentageValueChanged(app, ~)
value = app.DPercentage.Value;
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 = 'UI Figure';
% Create Asphalt
app.Asphalt = uiaxes(app.UIFigure);
title(app.Asphalt, '')
xlabel(app.Asphalt, '')
ylabel(app.Asphalt, '')
app.Asphalt.ClippingStyle = 'rectangle';
app.Asphalt.TickLength = [0 6];
app.Asphalt.Box = 'on';
app.Asphalt.XTick = [0 0.2 0.4 0.6 0.8 1];
app.Asphalt.YTick = [0 0.2 0.4 0.6 0.8 1 2];
app.Asphalt.YTickLabel = {'0'; '0.2'; '0.4'; '0.6'; '0.8'; '1'; '2'};
app.Asphalt.ZTick = [];
app.Asphalt.Color = [0 0 0];
app.Asphalt.BackgroundColor = [0.9412 0.9412 0.9412];
app.Asphalt.Position = [237 53 394 325];
% Create RunKOPDOCButton
app.RunKOPDOCButton = uibutton(app.UIFigure, 'push');
app.RunKOPDOCButton.ButtonPushedFcn = createCallbackFcn(app, @RunKOPDOCButtonPushed, true);
app.RunKOPDOCButton.BackgroundColor = [1 1 0];
app.RunKOPDOCButton.Position = [64 32 100 22];
app.RunKOPDOCButton.Text = 'Run KOP DOC';
% Create CLTitle
app.CLTitle = uilabel(app.UIFigure);
app.CLTitle.HorizontalAlignment = 'right';
app.CLTitle.Position = [30 364 51 22];
app.CLTitle.Text = 'Location';
% Create CLocation
app.CLocation = uieditfield(app.UIFigure, 'text');
app.CLocation.ValueChangedFcn = createCallbackFcn(app, @CLocationValueChanged, true);
app.CLocation.Position = [96 364 100 22];
% Create CPTitle
app.CPTitle = uilabel(app.UIFigure);
app.CPTitle.HorizontalAlignment = 'right';
app.CPTitle.Position = [14 332 67 22];
app.CPTitle.Text = 'Percentage';
% Create CPercentage
app.CPercentage = uieditfield(app.UIFigure, 'text');
app.CPercentage.ValueChangedFcn = createCallbackFcn(app, @CPercentageValueChanged, true);
app.CPercentage.Position = [96 332 100 22];
% Create PLTitle
app.PLTitle = uilabel(app.UIFigure);
app.PLTitle.HorizontalAlignment = 'right';
app.PLTitle.Position = [30 249 51 22];
app.PLTitle.Text = 'Location';
% Create PLocation
app.PLocation = uieditfield(app.UIFigure, 'text');
app.PLocation.ValueChangedFcn = createCallbackFcn(app, @PLocationValueChanged, true);
app.PLocation.Position = [96 249 100 22];
% Create PPTitle
app.PPTitle = uilabel(app.UIFigure);
app.PPTitle.HorizontalAlignment = 'right';
app.PPTitle.Position = [14 217 67 22];
app.PPTitle.Text = 'Percentage';
% Create PPercentage
app.PPercentage = uieditfield(app.UIFigure, 'text');
app.PPercentage.ValueChangedFcn = createCallbackFcn(app, @PPercentageValueChanged, true);
app.PPercentage.Position = [96 217 100 22];
% Create DLTitle
app.DLTitle = uilabel(app.UIFigure);
app.DLTitle.HorizontalAlignment = 'right';
app.DLTitle.Position = [30 134 51 22];
app.DLTitle.Text = 'Location';
% Create DLocation
app.DLocation = uieditfield(app.UIFigure, 'text');
app.DLocation.ValueChangedFcn = createCallbackFcn(app, @DLocationValueChanged, true);
app.DLocation.Position = [96 134 100 22];
% Create DPTitle
app.DPTitle = uilabel(app.UIFigure);
app.DPTitle.HorizontalAlignment = 'right';
app.DPTitle.Position = [14 102 67 22];
app.DPTitle.Text = 'Percentage';
% Create DPercentage
app.DPercentage = uieditfield(app.UIFigure, 'text');
app.DPercentage.ValueChangedFcn = createCallbackFcn(app, @DPercentageValueChanged, true);
app.DPercentage.Position = [96 102 100 22];
% Create CracksLabel
app.CracksLabel = uilabel(app.UIFigure);
app.CracksLabel.BackgroundColor = [0 0 1];
app.CracksLabel.HorizontalAlignment = 'center';
app.CracksLabel.FontWeight = 'bold';
app.CracksLabel.FontColor = [1 1 1];
app.CracksLabel.Position = [30 406 166 22];
app.CracksLabel.Text = 'Cracks';
% Create PotholesLabel
app.PotholesLabel = uilabel(app.UIFigure);
app.PotholesLabel.BackgroundColor = [1 0 0];
app.PotholesLabel.HorizontalAlignment = 'center';
app.PotholesLabel.FontWeight = 'bold';
app.PotholesLabel.FontColor = [1 1 1];
app.PotholesLabel.Position = [30 288 166 22];
app.PotholesLabel.Text = ' Potholes';
% Create DeliminationLabel
app.DeliminationLabel = uilabel(app.UIFigure);
app.DeliminationLabel.BackgroundColor = [0 1 0];
app.DeliminationLabel.HorizontalAlignment = 'center';
app.DeliminationLabel.FontWeight = 'bold';
app.DeliminationLabel.FontColor = [1 1 1];
app.DeliminationLabel.Position = [30 172 166 22];
app.DeliminationLabel.Text = 'Delimination';
% Create ROADREPLACEMENTANALYSISLabel
app.ROADREPLACEMENTANALYSISLabel = uilabel(app.UIFigure);
app.ROADREPLACEMENTANALYSISLabel.HorizontalAlignment = 'center';
app.ROADREPLACEMENTANALYSISLabel.Position = [270 393 344 30];
app.ROADREPLACEMENTANALYSISLabel.Text = 'ROAD REPLACEMENT ANALYSIS';
% 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 = KOPDOC_exported
% 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
I assigned a 6x6 matrix (with 36 squares) a number. Suppose to run the function and choose up to 5 squares (#1-36) And after choose a percentage (0.0, 0.2, 0.4, etc up to 1) And those squares suppose to change those colors based on the percentage. And it is suppose to do that for each parameters (potholes, cracks, etc). And if any of the squares are chosen more than once, than RGB suppose to activate and that specific square suppose to change to that specific color. Cracks are specifically blue, Potholes are red and delimination is green. I am stuck on how to make these conditions work. Please Help. Any help is greatly appreciated. Thank you
4 件のコメント
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/513216-drop-down-menu-to-gui-in-matlab-how-to-connect-drop-down-menu-to-the-function-and-callback#comment_816197
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/513216-drop-down-menu-to-gui-in-matlab-how-to-connect-drop-down-menu-to-the-function-and-callback#comment_816197
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/513216-drop-down-menu-to-gui-in-matlab-how-to-connect-drop-down-menu-to-the-function-and-callback#comment_816201
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/513216-drop-down-menu-to-gui-in-matlab-how-to-connect-drop-down-menu-to-the-function-and-callback#comment_816201
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/513216-drop-down-menu-to-gui-in-matlab-how-to-connect-drop-down-menu-to-the-function-and-callback#comment_816486
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/513216-drop-down-menu-to-gui-in-matlab-how-to-connect-drop-down-menu-to-the-function-and-callback#comment_816486
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/513216-drop-down-menu-to-gui-in-matlab-how-to-connect-drop-down-menu-to-the-function-and-callback#comment_816527
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/513216-drop-down-menu-to-gui-in-matlab-how-to-connect-drop-down-menu-to-the-function-and-callback#comment_816527
サインインしてコメントする。