Simple turn on Lamp with switch in app designer
I am trying to learn about app designer and have tried to make a basic app that turn the lamp GREEN if the switch is ON, and RED if the switch is OFF. For some reason there is no change in color of the lamp? I am using R2023a version of matlab.
function SwitchValueChanged(app, event)
disp(‘SwitchValueChanged callback triggered’); % Confirm function call
value = app.Switch.Value;
disp([‘Switch value: ‘, value]); % Display switch value
if strcmp(value, ‘on’)
disp(‘Setting lamp color to green’) % Debugging message
set(app.Lamp,’Color’,’green’)
elseif strcmp(value, ‘off’)
disp(‘Setting lamp color to red’) % Debugging message
set(app.Lamp,’Color’,’red’)
end
endI am trying to learn about app designer and have tried to make a basic app that turn the lamp GREEN if the switch is ON, and RED if the switch is OFF. For some reason there is no change in color of the lamp? I am using R2023a version of matlab.
function SwitchValueChanged(app, event)
disp(‘SwitchValueChanged callback triggered’); % Confirm function call
value = app.Switch.Value;
disp([‘Switch value: ‘, value]); % Display switch value
if strcmp(value, ‘on’)
disp(‘Setting lamp color to green’) % Debugging message
set(app.Lamp,’Color’,’green’)
elseif strcmp(value, ‘off’)
disp(‘Setting lamp color to red’) % Debugging message
set(app.Lamp,’Color’,’red’)
end
end I am trying to learn about app designer and have tried to make a basic app that turn the lamp GREEN if the switch is ON, and RED if the switch is OFF. For some reason there is no change in color of the lamp? I am using R2023a version of matlab.
function SwitchValueChanged(app, event)
disp(‘SwitchValueChanged callback triggered’); % Confirm function call
value = app.Switch.Value;
disp([‘Switch value: ‘, value]); % Display switch value
if strcmp(value, ‘on’)
disp(‘Setting lamp color to green’) % Debugging message
set(app.Lamp,’Color’,’green’)
elseif strcmp(value, ‘off’)
disp(‘Setting lamp color to red’) % Debugging message
set(app.Lamp,’Color’,’red’)
end
end appdesigner, app designer MATLAB Answers — New Questions