what is wrong with this small app?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi
I am trying to play around with my small list in this app but it seems matlab is not accepting my code.
Can anybody tell me whats wrong in it?
2 件のコメント
回答 (1 件)
Praveen Reddy
2023 年 4 月 10 日
Hi Mauzama,
I understand that you want to make the lamp glow green whenever user selects the first three values from the “ListBox”. In the call back function I could observe that you are comparing “value” with string, but “value” is a cell array of all the selected items.
if (strcmpi(value, 'CaCl2') && strcmpi(value,'MgCl2') && strcmpi(value, 'NH4Cl'))
app.Lamp.Color='g';
else
app.Lamp.Color='r';
end
Modify the if condition in the call back function as below
% Value changed function: ListBox
function ListBoxValueChanged(app, event)
value = app.ListBox.Value;
if(any(ismember(value,'CaCl2')) && any(ismember(value,'MgCl2')) && any(ismember(value,'NH4Cl')))
app.Lamp.Color='g';
else
app.Lamp.Color='r';
end
end
To know more about “ismember” and “any” functions, please refer to the following MATLAB documentation
- https://www.mathworks.com/help/matlab/ref/double.ismember.html
- https://www.mathworks.com/help/matlab/ref/any.html
I hope the above information resolves your query.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Downloads についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!