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 Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by