Error in running GUI

4 次查看(过去 30 天)
poor kitty
poor kitty 2021-6-26
回答: Satwik 2025-4-24
Hi everyone, I got problem in runnin GUI. The 'selected Button' always show Unrecognized method, property, or field 'selectedButton' for class 'skin'.
% Selection changed function: SkinProblemButtonGroup
function SkinProblemButtonGroupSelectionChanged(app, event)
%turn on the button
selectedButton = app.SkinProblemButtonGroup.SelectedObject;
switch app.selectedButton.Text
case 'Hyperpigmentation'
app.HyperpigmentationButton.Value = true;
case 'Acne'
app.AcneButton.Value = true;
case 'Dullness'
app.DullnessButton.Value = true;
end
But in previous part, there is no problem with this commad
% Selection changed function: SkinTypeButtonGroup
function SkinTypeButtonGroupSelectionChanged(app, event)
%turn on the button
selectedButton = app.SkinTypeButtonGroup.SelectedObject;
switch selectedButton.Text
case 'NormalSkin'
app.NormalSkinButton.Value = true;
case 'CombinationSkin'
app.CombinationSkinButton.Value = true;
case 'DrySkin'
app.DrySkinButton.Value = true;
case 'OilySkin'
app.OilySkinButton.Value = true;
case 'SensitiveAkin'
app.SensitiveSkinButton.Value = true;
end
Can anyone tell me what's the problem? Thank you

回答(1 个)

Satwik
Satwik 2025-4-24
The error occurs due to the following line in the code:
switch app.selectedButton.Text
Here, 'selectedButton' is being referenced as a property of 'app' (app.selectedButton), but in the function, 'selectedButton' is defined as a local variable.
Therefore, the correct approach is to use the local variable directly, as:
switch selectedButton.Text
I hope this helps resolve the issue.

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by